Skip to content

Commit

Permalink
dorfstatus
Browse files Browse the repository at this point in the history
  • Loading branch information
YtvwlD committed Sep 28, 2023
1 parent def94d8 commit 4758049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/dashboards/chaosdorf.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%div{"data-id" => "cat", "data-view" => "Image"}
%div{"data-view" => "Clock"}
%div{"data-id" => "weather", "data-view" => "Weather"}
%div{"data-id" => "chaosdoor-mode", "data-title" => "Chaosdoor Mode", "data-view" => "Text"}
%div{"data-id" => "dorfstatus", "data-title" => "DorfStatus", "data-view" => "Text"}
.row
%div{"data-id" => "downlink-traffic", "data-max" => "1000000000", "data-min" => "0", "data-title" => "Downlink Traffic", "data-view" => "Meter", "data-suffix" => "bit/s"}
%div{"data-id" => "uplink-traffic", "data-max" => "50000000", "data-min" => "0", "data-title" => "Uplink Traffic", "data-view" => "Meter", "data-suffix" => "bit/s"}
Expand Down
16 changes: 8 additions & 8 deletions src/jobs/mqtt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
power_series = Array.new(20).fill(0)
music_status = {}
last_music_update = Time.now
last_door_state = "unknown"
last_dorfstatus = "unknown"

SCHEDULER.every '5m', :allow_overlapping => false, :first_in => 0 do |job|
client = MQTT::Client.new
Expand All @@ -17,7 +17,7 @@
puts "mqtt: connected to #{client.host} as #{client.client_id}."

client.subscribe('sensors/flukso/power/sum/30s_average') # power
client.subscribe('door/status') # door
client.subscribe('space/dorfstatus')
client.subscribe('space/bell') # door bell
client.subscribe('music/#') # music

Expand All @@ -40,19 +40,19 @@
end
data = power_series.map.with_index{ |n,i| {"x" => -i, "y" => n} }
send_event('power-total', { points: data, status: status, moreinfo: "total power consumption" })
elsif topic == 'door/status'
elsif topic == 'space/dorfstatus'
##################################
# D O O R #
# D O R F #
##################################
last_door_state = message
send_event('chaosdoor-mode', { text: message, status: "normal" } )
last_dorfstatus = message
send_event('dorfstatus', { text: message, status: "normal" } )
elsif topic == 'space/bell' # message is 'ringdingding'
##################################
# R I N G #
##################################
send_event('chaosdoor-mode', { text: message, status: "danger" } )
send_event('dorfstatus', { text: message, status: "danger" } )
SCHEDULER.in '10s' do
send_event('chaosdoor-mode', { text: last_door_state, status: "normal" } )
send_event('dorfstatus', { text: last_dorfstatus, status: "normal" } )
end
elsif topic.start_with?('music/')
##################################
Expand Down

0 comments on commit 4758049

Please sign in to comment.