Hi
I have an SDM120 modbus energy meter connected to a Raspberry Pi with Domoticz.
There is a scheduled script that that reads the modbus and sorting out values to send them to Domoticz.
That works great - but I want it to send the data to HA at same time …
This is how the script send data to Domoticz:
curl -s {$SERVER"/json.htm?type=command¶m=addlogmessage&message="SDM120Update_FAILED!!!""} #send loginfo to domoticz
curl -s {$SERVER"/json.htm?type=command¶m=udevice&idx="864"&nvalue=0&svalue="$TOTAL""} #send total to Domoticz (energy "kWh")
curl -s {$SERVER"/json.htm?type=command¶m=udevice&idx="886"&nvalue=0&svalue="$POWER";"$TOTAL""} #send POWER/TOTAL to Domoticz to calculate daily kWh used
curl -s {$SERVER"/json.htm?type=command¶m=udevice&idx="859"&nvalue=0&svalue="$VOLTAGE""} #send voltage to Domoticz (voltage "V")
curl -s {$SERVER"/json.htm?type=command¶m=udevice&idx="869"&nvalue=0&svalue="$POWER""} #send power to Domoticz (power "W")
curl -s {$SERVER"/json.htm?type=command¶m=udevice&idx="870"&nvalue=0&svalue="$AMPERE""} #send ampere to Domoticz (current "A")
I want to send the same data to HA, and thinking like this:
curl -X POST -H "%auth%" -H "Content-Type: application/json" -d "{"voltage": "$VOLTAGE", "power": "$POWER", "energy": "$TOTAL", "current": "$AMPERE"}" http://homeassistant.local:8123/api/webhook/SDM120
But I am not sure how to set it up in HA…
I have searched alot and found bits and pieces, I guess that I need an “Automation” to use webhooks, but I have no idea how to configure that with sensors - and how to use unit_of_measurement, device_class and data_type.
I have seen value_template, but I am very new to HA (abt. 2 weeks) and have not really grasped the concept of templates and when to use them or not.
Is is something like this?
- name: "SDM120_V"
state: "{{ trigger.json.voltage }}"
unit_of_measurement: V
data_type: float
Can someone point me in the right direction?
Best regards