From 4758049c6a895b2d69c585a583fcc2f593ef30f6 Mon Sep 17 00:00:00 2001 From: Niklas Sombert Date: Thu, 28 Sep 2023 20:08:35 +0200 Subject: [PATCH] dorfstatus --- src/dashboards/chaosdorf.haml | 2 +- src/jobs/mqtt.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dashboards/chaosdorf.haml b/src/dashboards/chaosdorf.haml index 09f1592..07c31dc 100644 --- a/src/dashboards/chaosdorf.haml +++ b/src/dashboards/chaosdorf.haml @@ -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"} diff --git a/src/jobs/mqtt.rb b/src/jobs/mqtt.rb index 3e82866..d731e1e 100644 --- a/src/jobs/mqtt.rb +++ b/src/jobs/mqtt.rb @@ -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 @@ -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 @@ -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/') ##################################