@@ -94,15 +94,11 @@ class InSyncState < StatePattern::State
|
||||
reading.save
|
||||
end
|
||||
|
||||
# Write to EmonHub
|
||||
begin
|
||||
TCPSocket.open("printserver",5050){|s|
|
||||
s.write(sprintf("8 %d %d\r\n", reading.current_kw_consumed*1000, reading.current_kw_produced*1000))
|
||||
}
|
||||
rescue
|
||||
p "Socket problem."
|
||||
end
|
||||
# Result
|
||||
# Post current_kw_consumed and current_kw_produced to MQTT
|
||||
MqttClient.publish("home/energy/current_kw_consumed", reading.current_kw_consumed.to_s)
|
||||
MqttClient.publish("home/energy/current_kw_produced", reading.current_kw_produced.to_s)
|
||||
|
||||
# Result
|
||||
return reading
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user