as the weather in Belgium is not that good for a while, this is a bug a just detected today…
Everything should be OK now…
I’ve installed HA a couple of days ago.
The idea was to control my heatpump with the output module of my smappee.
The house has a 3 phase connection and also the heatpump and the PV inverter is 3 phase.
In smappee I’m monitoring the net, solar and the heatpump consumption.
With the code mentioned above, I get incorrect values in the overview.
Can someone guide me on how the code needs to be adjusted to accommodate with a 3 phase connection.
I’ve managed to get the readings of the individual phases for both grid and solar by adding the code below to the sensor.yaml file.
How do I get the total of the 3 phases combined?
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee GRID L1"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[0].power}}"
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee GRID L2"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[1].power}}"
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee GRID L3"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[2].power}}"
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee SOLAR L1"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[3].power}}"
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee SOLAR L2"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[4].power}}"
- platform: mqtt
state_topic: "servicelocation/UUID/realtime"
name: "Smappee SOLAR L3"
unit_of_measurement: "W"
value_template: "{{value_json.channelPowers[5].power}}"
excuse my ignorance, but where do you get the UUID values from?
You think that you can create a new sensor “totalsolar” by adding the three Solar entities together.
something like this:
- platform: template
sensors:
totalsolar:
friendly_name: “Solar Production”
value_template: “{ states(‘sensor.xxxx3’) | float + states(‘sensor.xxx4’) | float + states(‘sensor.xxx5’) | float}”
unit_of_measurement: ‘W’
You can get the UUID by logging into the smappee via a webbrowser.
surf to http://<SMAPPEE_IP>/smappee.html log in with password “admin”.
Alternative is to add the Location configuration CARD on your dashboard.smappee.net
I did manage to get the total value the way you suggested.
I’m at work now, and can’t access HA from here, I’ll post the code when I’m at home tonight.
I am in the Smappee webbrowser, but which value is the UUID? is it smappee and then the serial number of the smappee equipment?
I can’t see it here at work.
if you go to dashboard.smappee.net you can add the card Location Configuration. There’s a field called UUID, you can’t miss.
thanks, got it.
@browetd
I can’t seem to get any of this to work… (total noob here)
I created the 2 files and copied everything in it
sensors are 0, unknown or not available and I don’t really know what I did wrong
Do you mind helping me out?
Share you configuration/code It is very difficult to help you without seeing what you have already done…
In what file do you write the automations for switching tariff?
Utility_meter.yaml also?
automation is in the automation file
Thank you very much
Wow @browetd, many thanks! Took a bit of time understand the logic behind it, but got it working. Not sure if I could have done it without your code.
Some small questions: any plans to add the smappee gas meter also?
And I see you added a sensor called solar_house_consumption but you are not using it, what is the purpose? In fact the same applies for the daily, weekly, monthly & yearly entities: what is their purpose - something outside the energy dashboard?
Hi Didier, thanks for this guide, it helped me a lot as I’m new to HA and currently trying to migrated my existing setup from Domoticz. I have the above setup implemented and I’ve managed to read my Smappee values. I am getting error messages about the energy measurements in your template.yaml, stating that the wrong unit is used (W) while device_class energy requires kWh instead. Do you know if that is something which has changed recently? Any suggestions how I can make this work? Thank you!
EDIT: I think I’ve managed to fix it already. In those 4 entries (solar_production, solar_house_consumption, solar_imported_power_w and solar_exported_power_w) I set device_class to power instead of energy.
Hello… I have not added one but two Smappee gas&water meters to my configuration: one for gas and the other for water… :wink
Why two ? Because of the distance between the two meters…
I am off for a week but when I come back home, I will answer your question and share the code, this took me some efforts as Smappee is sending nothing, one or two json records based on what has been consumed in the last 5 minutes… Stay tuned…
Correct, device_class must be “power” for entities finishing with _W in my configuration.
Here is the sequence for two smappee gas&water with one installed probe on each device… I had to install two because the two meters (gas and water) are too far away from each other to use one smappee with two probes.
First I read the record from the smappee using mqtt, than I split the record in one or two sub-records based on the symbol “}”, I create/update/reformat one or two mqtt topics (record1 and record2) based on what I read: one sub-record with consumption of water or gas, two sub-records with consumption of water and gas (when there are two sub-records, they are always presented the same way: water first and gas second… but this is depending of your installation/configuration):
- alias: read_smappee_record
trigger:
platform: mqtt
topic: servicelocation/<your_smappee_id>/aggregatedGW
action:
- variables:
data: "{{ trigger.payload.split('}') }}"
- service: mqtt.publish
data:
topic: 'homeassistant/smappee/record1'
payload: '{{ (data[0])[20:]+"}" }}'
- condition: '{{ ((data[1])[0:1]) != "]" }}'
- service: mqtt.publish
data:
topic: 'homeassistant/smappee/record2'
payload: '{{(data[1])[1:]}}}'
Here is an example of the data received from the smappee (one sub record):
{"utcEndtime":1653153000000,"sensorId":4,"index0Delta":9,"index1Delta":0,"temperature":184,"humidity":94,"battLevel":90,"version":1}
or with two sub-records:
{"utcEndtime":1653153000000,"sensorId":4,"index0Delta":9,"index1Delta":0,"temperature":184,"humidity":94,"battLevel":90,"version":1},{"utcEndtime":1653153000000,"sensorId":5,"index0Delta":4,"index1Delta":0,"temperature":173,"humidity":90,"battLevel":80,"version":1}
As you can see, if you have only one smappee with two sensors, you have the delta index for both in the same sub-record (pretty easy)… It is way more complicated with two smappee, in this case utcEndtime are identical for the two sub-records if read at the same time (but if there is no water or gas consumption, you will get only one sub-record and consequently two different utcEndtime for record1 and record2), you have the sensorid to know if the sub-record is for water (sensorId = “4”) or gas meter (sensorId = “5”), the temperature, the humidity and the battery level of the smappee device…
Then from those two sub-records (record1 and record2 stored in mqtt) I create the sensors I need (and the calculation below is also dependant of your configuration and the type of meter you have (mine are giving one liter per pulse read by the smappee device):
- platform: mqtt
state_topic: "homeassistant/smappee/record1"
name: "Smappee Sensor Index 1"
value_template: "{{ value_json['sensorId'] | int(default=0) }}"
- platform: mqtt
state_topic: "homeassistant/smappee/record1"
name: "Smappee Sensor Value 1"
unit_of_measurement: "L"
value_template: "{{ (((value_json['index0Delta'] | float(default=0)) * (1 + (9 * (value_json['sensorId'] | int(default=0) == 5))) )+ ((value_json['sensorId'] | int(default=0) == 4) * (states('input_number.flip_flop_eau') | float(default=0)) /100) + ((value_json['sensorId'] | int(default=0) == 5) * (states('input_number.flip_flop_gaz') | float(default=0)) /100)) | round(2) }}"
- platform: mqtt
state_topic: "homeassistant/smappee/record1"
name: "Smappee Sensor Time 1"
value_template: "{{ value_json['utcEndtime'] | int(default=0) }}"
- platform: mqtt
state_topic: "homeassistant/smappee/record2"
name: "Smappee Sensor Index 2"
value_template: "{{ value_json['sensorId'] | int(default=0) }}"
- platform: mqtt
state_topic: "homeassistant/smappee/record2"
name: "Smappee Sensor Value 2"
unit_of_measurement: "L"
value_template: "{{ (((value_json['index0Delta'] | float(default=0)) * (1 + (9 * (value_json['sensorId'] | int(default=0) == 5))) )+ ((value_json['sensorId'] | int(default=0) == 4) * (states('input_number.flip_flop_eau') | float(default=0)) /100) + ((value_json['sensorId'] | int(default=0) == 5) * (states('input_number.flip_flop_gaz') | float(default=0)) /100)) | round(2) }}"
- platform: mqtt
state_topic: "homeassistant/smappee/record2"
name: "Smappee Sensor Time 2"
value_template: "{{ value_json['utcEndtime'] | int(default=0) }}"
“sensor.smappee_sensor_value_1” is the delta index read since the last update for record1 and the other for record2 if updated at the same time. I use a flip_flop variable to change slightly the value of those two sensors (by: 0,001 liter) to have an update of the utility meters and other sensors at every smappee record update…
Then I have the “sensor.smappee_sensor_index_1” containing the sensorId reported in record1 (can be 4 (if water consumption) or 5 (if gas consumption but no water consumption since the last update)) and “sensor.smappee_sensor_index_2” containing the sensorId reported in record 2 (can only by 5 as the first record in this case has a recordId of 4: water first, gas second)…
“sensor.smappee_sensor_time_1” and “sensor.smappee_sensor_time_2” are corresponding timestamps when record1 and record2 were updated (could be the same if two sub-records read at the last update, could be different if only one sub-record is read at the last update).
Finally… I create the two sensors with water and gas consumption (updated when the timestamp is changed, so the sub-record is updated…):
- name: "smappee usage water c litres"
unit_of_measurement: "L"
state: >-
{{ ((states('sensor.smappee_sensor_time_1') | int(default=0)) * 0) + ((states('sensor.smappee_sensor_index_1') | int(default=0) == 4) * ((states('sensor.smappee_sensor_value_1') | float(default=0)))) | round(2) }}
- name: "smappee usage gaz c litres"
unit_of_measurement: "L"
state: >-
{%if states.sensor.smappee_sensor_time_1.state == states.sensor.smappee_sensor_time_2.state %}
{{ ((states('sensor.smappee_sensor_time_2') | int(default=0)) * 0) + ((states('sensor.smappee_sensor_index_2') | int(default=0) == 5) * ((states('sensor.smappee_sensor_value_2') | float(default=0)))) | round(2) }}
{% else %}
{{ ((states('sensor.smappee_sensor_time_1') | int(default=0)) * 0) + ((states('sensor.smappee_sensor_index_1') | int(default=0) == 5) * ((states('sensor.smappee_sensor_value_1') | float(default=0)))) | round(2) }}
{% endif %}
Pretty complex I fully agree, it should way easier with only one smappee gas&water… but I am not in that configuration… Maybe there are some potential simplification in the process but it is working for me…
If you have questions, do not hesitate
Hey all, i hope it is ok to pick up this thread again.
first of all: many thanks to Didier for your explanation and the code you provided! It helped me a lot to integrate my smappee energy monitor into my HA.
Anyhow - i am struggling now to integrate the readings of the GAS Sensor.
I was trying to reproduce the steps in the last post - but maybe due to lack of knowledge, I don’t understand it and am not able to create values.
In fact, i am suck at the point to retrieve data from the sensor at all.
In the MQTT Message i see topic “gwSensorChannelsConfig”, but there is not the mentioned response with ‘index0Delta’ included.
Any hint into the right direction would be highly appreciated.
Many thanks and best regards
Alex
@samarkande So if I understand correctly, you can read the records send by the Smappee device to MQTT…
Can you share the record that you are getting from MQTT and that you think is associated with the Gas&Water Meter ?
You can get all the records coming from the smappee by typing the following command (if you are using mosquitto as MQTT broker):
mosquitto_sub -t "servicelocation/ <your_smappee_id>/#" -h <MQTT_broker_local_IP_address> -u <MQTT_user> -P <MQTT_password>
Try to identify the record associated with the gas & water smappee… Not easy as you will have a bunch of records every seconds (mainly coming from the power sensors)…
IMPORTANT: Please mention that you are getting a record from the gas&meter device every 5 minutes when there is gas consumption… No consumption, means no record send by the smappee for the gas consumption until you start to consume some gas, than a record is issued after about 5 minutes…