Smappee solar production not available for Energy function

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? :yum:

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…

1 Like

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…

Hey,

thanks for the fast reply.
I use mosquitto as MQTT broker. If i go to config, I can listen to everything on servicelocation (where i recieve the Smappee values from).

In Topic “servicelocation//sensorConfig” I get some info about the Water/Gas sensor (only Gas connected and configured):

{
    "utcTimeStamp": 1659650060872,
    "gwSensors": [
        {
            "gwSensorChannelsConfig": [
                {
                    "leakIntervals": 0,
                    "maxPulses": 0,
                    "ppu": 1,
                    "uom": "NONE",
                    "enabled": false,
                    "type": "NONE"
                },
                {
                    "leakIntervals": 1,
                    "maxPulses": 0,
                    "ppu": 100,
                    "uom": "m3",
                    "enabled": true,
                    "type": "GAS"
                }
            ],
            "sensorId": 1,
            "serialNumber": "####"
        }
    ],
    "switchSensors": []
}

The 5 min intervall might be a possible solution to the problem, as I never saw the aggregatedGW in the topics.

If I understand your code right, i should recieve the data for “SensorID”: 1 with one sub record, as only one sensor is configured, every 5 min or so, as long as there was consumption.
Am I right so far?

@samarkande Correct but as I have two separate gas&water devices, maybe SMAPPEE is formatting the record differently before sending it to MQTT… Nevertheless the information will come to MQTT from gas&water only if you have consumption… otherwise SMAPPEE is quiet and silent… One tool that I found yesterday and seems very useful (and free !!!) is “MQTT-Explorer” (you can see all the topics available in mosquitto and see their values in real time, so you do not have to wait for the record to appear, just open it and let it run), this tool is available in the windows store… Here is the link:

Hello,

I’m only using one sensor and only for water, but following settings work for me:
I suppose you only have to change the 3 in measurements[3] to get the gas readings.

0 is the temperature of the smappee sensor
1 is the battery percentage
2 is the humidity
3 is the water usage

Added to the MQTT sensors in configuration.yaml:

    - state_topic: "servicelocation/<your_smappee_id>/aggregatedGW"
      name: "smappee sensor water"
      unit_of_measurement: "L"
      value_template: "{{value_json.gwIntervalDatas[0].measurements[3].value | float(default=0)}}"

To define the correct string for the value template I used https://jsonpathfinder.com
On the left side replace the code with the AggregatedGW message. You can also make the message more readable. (Beautify)
As Didier already mentioned, MQTT Explorer is a great help to get the correct Smappee message.
Then on the right side you can search for the value you are looking for and on the top right you have the string to get that value. Replace the x at the front with value_json and you have the correct string.

Next I added a sensor to template.yaml:

  - name: "water usage"
    unique_id: water_usage
    unit_of_measurement: "L"
    state: "{{(states('sensor.smappee_sensor_water') | float(default=0))}}"

And finally the sensors to utility_meter.yaml:

# Water consumption
water_usage_hourly:
    source: sensor.water_usage
    name: Water Usage Hourly
    cycle: hourly
    delta_values: true
    tariffs:
        - peak
water_usage_daily:
    source: sensor.water_usage
    name: Water Usage Daily
    cycle: daily
    delta_values: true
    tariffs:
        - peak
water_usage_weekly:
    source: sensor.water_usage
    name: Water Usage Weekly
    cycle: weekly
    delta_values: true
    tariffs:
        - peak
water_usage_monthly:
    source: sensor.water_usage
    name: Water Usage Monthly
    cycle: monthly
    delta_values: true
    tariffs:
        - peak
water_usage_yearly:
    source: sensor.water_usage
    name: Water Usage Yearly
    cycle: yearly
    delta_values: true
    tariffs:
        - peak

Hope this helps.

Hey all,

sorry for the late reply - had no time to play around in the last days :slight_smile:

Thanks at Didier for the MQTT-Explorer tip. this helped to identify the Messages for the Gas Sensor and to see, that something is delivered :wink:

Big thanks to Boromin for your integration and the supporting steps. I imported your way into my config and hope, that it is working… just need some gas usage to happen.
The integration of Didier was to complicated for me to understand. Maybe with time i will learn and understand.

I’ll keep you updated, if my attempt was successful

cheers and again: Thanks for all the support

Well, I can confirm it is working!

Sensor config (via MQTT Integration):

 #Gas Sensor integration
  - name: "smappee gas sensor"
    state_topic: "servicelocation/<deviceID>/aggregatedGW"
    unit_of_measurement: "m³"
    value_template: "{{((value_json.gwIntervalDatas[0].index1Delta | float(default=0))/1000)}}"

My meter is measuring m³ with 3 digits after 0, this is why i devided the value by 1000.
Also my Smappee does not group the values within “measurements”.

in template.yaml I added the sensor:

#Smappe GAS integration
  - name: gas_verbrauch
    unique_id: gas_consumption_m3_uid
    unit_of_measurement: "m³"
    state_class: total_increasing
    device_class: gas
    state: "{{(states('sensor.smappee_gas_sensor') | float(default=0))}}"

The value “gas_verbrauch” I am using as input for utility_meter and could also select it as gas input for the energy dashboard.

hope this also helps anyone.
Again - thanks for all the help!

Hi all,
Looking to replicate some of the functionality above. I’ve got MQTT working and sending numbers through, the realtime looked too much data, so going to use the aggregated 5 minute data, but can’t seem to work out what the numbers mean. From the dashboard.smappee.net site, it looks like the numbers I’m expecting are:
Consumption:2584.8
Production:2565.6
Import: 19.2

Does anyone know how to convert the numbers into something more meaningful?

intervalDatas [1]
0 {5}
utcEndtime : 1661697000000

2022-08-28T14:30:00.000Z


averageRMSVoltage : 2452
alwaysOn : 10058
channelIntervalDatas [3]
0 {7}
averageRMSCurrent : 3753
averageImportRMSActivePower : 28842
averageExportRMSActivePower : 245
averageRMSApparentPower : 921260
averageRMSReactivePower : 920745
averagePowerfactor : 2
ctInput : 0
1 {7}
averageRMSCurrent : 2005
averageImportRMSActivePower : 420756
averageExportRMSActivePower : 0
averageRMSApparentPower : 492174
averageRMSReactivePower : 255329
averagePowerfactor : 84
ctInput : 1
2 {7}
averageRMSCurrent : 3314
averageImportRMSActivePower : 449355
averageExportRMSActivePower : 0
averageRMSApparentPower : 813397
averageRMSReactivePower : 677842
averagePowerfactor : 54
ctInput : 2

Answered my own question and linking to it here for completeness - this gives 5 minute power/energy calculations.

Cheers.

Colin

My smappee solar went dead… Anyone here not using their solar version anymore? I’m interested to buy it

Hi, what smappee device do you have? i dont see any aggegratedGW , only aggegrated ?

Hi @Boromin , thnx for your posts, about your config, I’m using the cloud option to extract gas/water , it gives me indeed these 2 sensors, based on daily usage:

to use them, i need to make 2 utility sensors like this?

water_usage_hourly:
    source: sensor.pergola_quintens_sensor_water
    name: Water Usage Hourly
    cycle: hourly
    delta_values: true
    
gas_usage_hourly:
    source: sensor.pergola_quintens_sensor_gas
    name: Gas Usage Hourly
    cycle: hourly
    delta_values: true

For the water? is L converted to m3 , since L is not supported?
What about the reset, since these 2 sensors are daily sensors and are resetted back to 0 at 00:00
Will this not give issues on the utility sensor ? or is that the meaning/purpose of the delta value?

here is a screenshot of the gas:

isnt that wrong? the last period was 6.11 , now next hour its 6.15 , and utility meter collected also 6.15 ? should it collect only the difference?

Hi all,

I’m trying to understand this for myself, but as i’m a NOOB its very hard.

The problem for my is that a friend of my asked me to help him with Smappee and HA and specialy the energy page.

So, her it is…
He is living in an appartment and he wants to show all the residents some information about the energy and solar etc from the building…

Can you please help me with a “How to” to get this working via MQTT.
I know where to find the MQTT installation, but I can’t find the “Scenes.yaml” in Studio Code Server. Is that something to create before puting the data in it?

Hello, I don’t know if it can help, but I created a sensor (settings > Device & services > helpers ) type: integral sensor (Left Rieman sum) on my smappee power, and now I have it available in energy dahsboard , without MQTT, … just with SMAPPEE integration