Open svh1985 opened 3 years ago
@svh1985 I'm no home assistant user, this auto discovery is build according to the specs (some time ago). Apparently they don't work.
How should the auto discovery messages be formatted? Did you turn on mqtt auto discovery in home assistant?
I've just setup a home assistant instance just to test this. It seems the discovery message (which is exactly as documented) is not working. Changing them to the same format as zigbee2mqtt and they get picked up immediately.
What values would you like to see in home assistant?
I would like build a dashboard that includes this information:
Let me know if I can do something to help/test :)
:tada: This issue has been resolved in version 1.7.0-beta.7 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Small sample:
@svh1985 you could test the latest beta and see if it works for you now, the docker version is currently building, see https://github.com/svrooij/smartmeter2mqtt/runs/3002295741 (usually takes +/- 14 minutes)
@svrooij
It seems the discovery message (which is exactly as documented) is not working. Changing them to the same format as zigbee2mqtt and they get picked up immediately.
Can you give some examples of what you tried which didn't work?
Documentation is here:
@emontnemery I didn't see the second page when I implemented this a year ago. After this change the sensors started appearing. Do you need me to write out the config messages or can you see it in the changes? https://github.com/svrooij/smartmeter2mqtt/commit/d35eb6d4dd51823b1dd0eaf1c1380b242e4813f0#diff-3a9eff3aa76cd9e481d818b422f653ebf166101cc97a5842b684c1caaf555128L104-L118
The object is converted to json before sending to mqtt.
I downloaded the new beta and only the current Tarrif is picked up:
HA
MQTT
@svrooij The change makes substantial changes to the functionality though; you now tie the sensors to a device object in Home Assistant but you also remove the availability
feature, which means the sensors will always appear as available in Home Assistant.
If sensors are not tied to a device, they will show up as orphans under the MQTT integration as well as under entities but not be listed under devices.
Before this change, what went wrong or didn't work as expected?
By the way:
state_class
to measurement
for a certain sensor, that sensor will be included in Home Assistant's long term statistics, you probably want to do that for all the sensors.last_reset_topic
for them to be included in long term statistics. If the smartmeter energy consumption never resets, you can set the last_reset_topic
to same as state_topic
and also declare a last_reset_value_template
which returns UNIX epoch 0: {{ "1970-01-01T00:00:00+00:00" }}
@emontnemery this didn't work. I need to mention, I myself am no home assistant user, so adding home assistant support is just for others to enjoy.
The sensors where not picked up (as stated by @svh1985 ), I then started a clean home assistant installation as a docker container in windows (which just works as opposed to the documentation saying not working). And connected it to my already being used mqtt server. The entities didn't show up. So I guess that can be called not working.
I then just tried to send out the same config file as zigbee2mqtt
does.
I don't use this part myself, but want to help others, this (home assistant discovery) is included. If it needs changing please state what should be send instead of the current messages (this is de latest version that is building as we speak).
Power usage:
{
"availability": [
{
"topic": "smartmeter/connected",
"payload_available": "2"
}
],
"device": {
"identifiers": [
"smartmeter_xxx"
],
"model": "KFM5KAIFA-METER",
"name": "DSMR power 33137",
"sw_version": "smartmeter2mqtt (0.0.0-development)"
},
"device_class": "power",
"state_class": "measurement",
"json_attributes_topic": "smartmeter/status/energy",
"state_topic": "smartmeter/status/energy",
"name": "Current power usage",
"icon": "mdi:transmission-tower",
"unit_of_measurement": "Watt",
"value_template": "{{ value_json.calculatedUsage }}",
"unique_id": "smartmeter_xxx_current-usage"
}
With these latest messages, the devices just show up, like here. 🎉
Starting home assistant in docker on windows docker run --init -d --name homeassistant -v /etc/localtime:/etc/localtime:ro -v /mnt/c/Users/my-username/.ha:/config -p 8123:8123 ghcr.io/home-assistant/home-assistant:stable
Hi, was playing around with this one to see if I can use it to move from Domoticz to Home Assistant. Am running into the same issue when using the latest build and want to try the beta version but it gives "# Fatal error in , line 0". Would be great if you could help me with this.
Thanks!
For those running into the same issue: I managed to get it work using smartmeter2mqtt-latest version by adding this to my configuration.yaml:
# template for Energy mqtt sensor
template:
- sensor:
- name: "Electricity Usage"
unique_id: "DSMREU01"
unit_of_measurement: "kWh"
state: >
{{ states("sensor.current_power_usage") | float(0) / 1000 }}
device_class: energy
state_class: total
- name: "Electricity Usage T1"
unique_id: "DSMRTU01"
unit_of_measurement: "kWh"
state: >
{{ states("sensor.total_power_used_t1") | float(0) }}
device_class: energy
state_class: total_increasing
- name: "Electricity Usage T2"
unique_id: "DSMRTU02"
unit_of_measurement: "kWh"
state: >
{{ states("sensor.total_power_used_t2") | float(0) }}
device_class: energy
state_class: total_increasing
- name: "Electricity Return T1"
unique_id: "DSMRTR01"
unit_of_measurement: "kWh"
state: >
{{ states("sensor.total_power_delivered_t1") | float(0) }}
device_class: energy
state_class: total
- name: "Electricity Return T2"
unique_id: "DSMRTR02"
unit_of_measurement: "kWh"
state: >
{{ states("sensor.total_power_delivered_t2") | float(0) }}
device_class: energy
state_class: total
- name: "Gas Usage"
unique_id: "DSMRGU01"
unit_of_measurement: "m³"
state: >
{{ states("sensor.total_gas_usage") | float(0) }}
device_class: gas
state_class: total_increasing
Hello,
I'm trying to connect the HA, but for some reason HA doesn't pick up the data using auto discovery. I'm not sure what I'm doing wrong. Do I need to add some additional config?
The MQTT messages are published, (filtered view of) MQTT structure:
Docker-Compose