This commit is contained in:
parent
495723fb32
commit
1066a980de
1 changed files with 23 additions and 0 deletions
|
@ -57,6 +57,29 @@ defmodule WeewxProxy.Modbus.Deye do
|
|||
{:ok, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_message(["bitshake", "tele", "smartmeter", topic], publish, state) do
|
||||
if topic == "SENSOR" do
|
||||
{:ok, meter_data} = Jason.decode(publish)
|
||||
|
||||
timestamp = DateTime.utc_now() |> DateTime.to_unix()
|
||||
day = get_in(meter_data, ["eBZ", "E_in"])
|
||||
active = get_in(meter_data, ["eBZ", "Power"])
|
||||
|
||||
mqtt_data = %{
|
||||
dateTime: timestamp,
|
||||
homeEnergyDay: day,
|
||||
homeEnergyActive: active
|
||||
}
|
||||
|
||||
:ok = Publisher.publish("weewx/ingest_si", mqtt_data)
|
||||
|
||||
{:ok, state}
|
||||
else
|
||||
{:ok, state}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_message(topic, publish, state) do
|
||||
full_topic = Enum.join(topic, "/")
|
||||
|
|
Loading…
Reference in a new issue