Smappee solar production not available for Energy function

Although Smappee has three sensors reporting solar production; total production active power, total production -current hour and total production - today none of them show up in the drop down menu when i try to add solar to the new Energy function.

An issue has been opened (homeassistant/core) to have that potentially fixed in a future releaseā€¦

1 Like

there s a PR going, but as you see in title of that issue/pr , its only for switches
i have loaded the new version, but the total production/consumtion, they still look the same

edit : nm, PR is changing :slight_smile:

1 Like

I got it working with my smappee sensors (using MQTT not the integration)ā€¦ Let me know if you are interested so I can share what I did based on this excellent post:

1 Like

Please share :slight_smile:

Here is what I added to my config: two files (template.yaml and utility_meter.yaml and a couple of sensors in sensors.yaml).

This is based on my sensors (already existing), the first one is the consumption of my house, the second the solar production and the third the difference of those two (if positive, I am injecting to the grid, if negative I am consuming from the grid)

- platform: mqtt
  state_topic: "servicelocation/8853e98f-b96e-4c14-8b60-32718b54f9f6/realtime"
  name: "Smappee usage c"
  unit_of_measurement: "W"
  value_template: "{{value_json.channelPowers[1].power}}" 

- platform: mqtt
  state_topic: "servicelocation/8853e98f-b96e-4c14-8b60-32718b54f9f6/realtime"
  name: "Smappee Solar c"
  unit_of_measurement: "W"
  value_template: "{{value_json.channelPowers[0].power}}" 

- platform: template
  sensors:
    smappee_injected:
      value_template: "{{ ((states('sensor.smappee_solar_c') | float) - (states('sensor.smappee_usage_c') | float)) | int }}"
      unit_of_measurement: "W"

I added two lines in configuration.yaml:

template: !include template.yaml
utility_meter: !include utility_meter.yaml

So the two files:
template.yaml:

# 
# entity for Energy management dashboard
#

sensor: 

  - name: "Solar Production"
    unique_id: solar_production
    state_class: measurement
    device_class: energy  
    unit_of_measurement: 'W'
    state: "{{(states('sensor.smappee_solar_c') | float)}}"

  - name: "Solar House Consumption"
    unique_id: solar_house_consumption
    state_class: measurement
    device_class: energy  
    unit_of_measurement: 'W'
    state: "{{(states('sensor.smappee_usage_c') | float)}}"

  - name: "Solar Imported Power W"
    unique_id: solar_imported_power_w
    state_class: measurement
    device_class: energy  
    unit_of_measurement: 'W'
    state: >
      {% if ((states('sensor.smappee_injected') | float) <= 0) %} 
        {{(-(states('sensor.smappee_injected') | float))}}
      {% else %}
        0
      {% endif %}

  - name: "Solar Exported Power W"
    unique_id: solar_exported_power_w
    state_class: measurement
    device_class: energy  
    unit_of_measurement: 'W'
    state: >
      {% if ((states('sensor.smappee_injected') | float) > 0) %} 
        {{(states('sensor.smappee_injected') | float)}}
      {% else %}
        0
      {% endif %}

utility-meter.yaml:

solar_imported_power_hourly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Hourly
    cycle: hourly
solar_imported_power_daily:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Daily
    cycle: daily 
solar_imported_power_weekly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Weekly
    cycle: weekly 
solar_imported_power_monthly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Monthly
    cycle: monthly 
solar_imported_power_yearly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Yearly
    cycle: yearly

solar_exported_power_hourly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Hourly
    cycle: hourly 
solar_exported_power_daily:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Daily
    cycle: daily 
solar_exported_power_weekly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Weekly
    cycle: weekly 
solar_exported_power_monthly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Monthly
    cycle: monthly 
solar_exported_power_yearly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Yearly
    cycle: yearly 

solar_production_hourly:
    source: sensor.solar_production_kwh
    name: Solar Production Hourly
    cycle: hourly 
solar_production_daily:
    source: sensor.solar_production_kwh
    name: Solar Production Daily
    cycle: daily 
solar_production_weekly:
    source: sensor.solar_production_kwh
    name: Solar Production Weekly
    cycle: weekly 
solar_production_monthly:
    source: sensor.solar_production_kwh
    name: Solar Production Monthly
    cycle: monthly 
solar_production_yearly:
    source: sensor.solar_production_kwh
    name: Solar Production Yearly
    cycle: yearly 

solar_house_consumption_hourly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Hourly
    cycle: hourly
solar_house_consumption_daily:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Daily
    cycle: daily 
solar_house_consumption_weekly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Weekly
    cycle: weekly 
solar_house_consumption_monthly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Monthly
    cycle: monthly 
solar_house_consumption_yearly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Yearly
    cycle: yearly     

And a couple of sensors:

# 
# entity for Energy management dashboard
#

- platform: integration
  source: sensor.solar_imported_power_w
  method: left
  unit_prefix: k
  name: solar_imported_power_kwh

- platform: integration
  source: sensor.solar_exported_power_w
  method: left
  unit_prefix: k
  name: solar_exported_power_kwh

- platform: integration
  source: sensor.solar_production
  method: left
  unit_prefix: k
  name: solar_production_kwh

- platform: integration
  source: sensor.solar_house_consumption
  method: left
  unit_prefix: k
  name: solar_house_consumption_kwh

Thatā€™s itā€¦ Wait a couple of hours (two should be enough) and you will see the entities appearing in the drop down list of the energy dashboard (only the oneā€™s that have been populated with data, so for me the exported entities are not shown as I have not yet exported electricity to the grid)ā€¦

I am now looking now to track the cost based on tariffs (will be configured for belgian hours/tariffs)

Have fun !

cool , thnx for sharing, also looking forward to belgium costs
btw, why are you using mqtt if you use only production and consumpion? those 2 entities are also discovered local without mqtt ?

I have included the costs (see below). I am using MQTT for both sites even if on one, I have no solar panel yet. I prefer to control the data from the source where it is possible and easy to implement/maintain.

For the costs, you just need to add ā€œtariffsā€ associated with the utility meters, so the file utility_meter.yaml is becoming:

solar_imported_power_hourly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Hourly
    cycle: hourly
    tariffs:
      - jour
      - nuit
solar_imported_power_daily:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Daily
    cycle: daily 
    tariffs:
      - jour
      - nuit
solar_imported_power_weekly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Weekly
    cycle: weekly 
    tariffs:
      - jour
      - nuit
solar_imported_power_monthly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Monthly
    cycle: monthly 
    tariffs:
      - jour
      - nuit
solar_imported_power_yearly:
    source: sensor.solar_imported_power_kwh
    name: Solar Imported Power Yearly
    cycle: yearly
    tariffs:
      - jour
      - nuit
      
solar_exported_power_hourly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Hourly
    cycle: hourly 
    tariffs:
      - jour
      - nuit
solar_exported_power_daily:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Daily
    cycle: daily 
    tariffs:
      - jour
      - nuit
solar_exported_power_weekly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Weekly
    cycle: weekly 
    tariffs:
      - jour
      - nuit
solar_exported_power_monthly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Monthly
    cycle: monthly 
    tariffs:
      - jour
      - nuit
solar_exported_power_yearly:
    source: sensor.solar_exported_power_kwh
    name: Solar Exported Power Yearly
    cycle: yearly 
    tariffs:
      - jour
      - nuit

solar_production_hourly:
    source: sensor.solar_production_kwh
    name: Solar Production Hourly
    cycle: hourly 
    tariffs:
      - jour
      - nuit
solar_production_daily:
    source: sensor.solar_production_kwh
    name: Solar Production Daily
    cycle: daily 
    tariffs:
      - jour
      - nuit
solar_production_weekly:
    source: sensor.solar_production_kwh
    name: Solar Production Weekly
    cycle: weekly 
    tariffs:
      - jour
      - nuit
solar_production_monthly:
    source: sensor.solar_production_kwh
    name: Solar Production Monthly
    cycle: monthly 
    tariffs:
      - jour
      - nuit
solar_production_yearly:
    source: sensor.solar_production_kwh
    name: Solar Production Yearly
    cycle: yearly 
    tariffs:
      - jour
      - nuit

solar_house_consumption_hourly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Hourly
    cycle: hourly
    tariffs:
      - jour
      - nuit
solar_house_consumption_daily:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Daily
    cycle: daily 
    tariffs:
      - jour
      - nuit
solar_house_consumption_weekly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Weekly
    cycle: weekly 
    tariffs:
      - jour
      - nuit
solar_house_consumption_monthly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Monthly
    cycle: monthly 
    tariffs:
      - jour
      - nuit
solar_house_consumption_yearly:
    source: sensor.solar_house_consumption_kwh
    name: Solar House Consumption Yearly
    cycle: yearly
    tariffs:
      - jour
      - nuit

You have then to write an automation to switch tariffs (hours here are for Belgium):

- alias: tarif_electricite
  initial_state: true
  trigger:
    - platform: time
      at: "07:00:00"
    - platform: time
      at: "22:00:00"
  condition:
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
    - service: utility_meter.next_tariff
      entity_id: 
        - utility_meter.solar_exported_power_hourly
        - utility_meter.solar_exported_power_daily
        - utility_meter.solar_exported_power_weekly
        - utility_meter.solar_exported_power_monthly
        - utility_meter.solar_exported_power_yearly
        - utility_meter.solar_imported_power_hourly
        - utility_meter.solar_imported_power_daily
        - utility_meter.solar_imported_power_weekly
        - utility_meter.solar_imported_power_monthly
        - utility_meter.solar_imported_power_yearly
        - utility_meter.solar_house_consumption_hourly
        - utility_meter.solar_house_consumption_daily
        - utility_meter.solar_house_consumption_weekly
        - utility_meter.solar_house_consumption_monthly
        - utility_meter.solar_house_consumption_yearly
        - utility_meter.solar_production_hourly
        - utility_meter.solar_production_daily
        - utility_meter.solar_production_weekly
        - utility_meter.solar_production_monthly
        - utility_meter.solar_production_yearly

Then you create the dashboard with your entities created with the tarriffsā€¦ like this example:

For the price of the electricity, you have to click on each entity and add the priceā€¦ like this example:

Here is the dashboard :

looking nice, appreciate the sharing
stuff to test later :slight_smile:

@browetd , i copy pasted all sensors, looking good,ā€¦ for now testing without tarrifs

but for some reason, i cant select exported sensors here? i cant see any of them on the combox, only the imported ones? what am i missing? that do excist though?

Until they are not populated with a value greather than 0, they will not appearā€¦ What I did, is to force them to a value of 1 for an hour or two and than they appeared in the drop down list (opportunity for improvements)ā€¦ Same for ā€œjourā€ ā€œnuitā€ utility meters, you have to switch from one tariff to the other to see those appearing in the listā€¦

ah ok, ill wait then :slight_smile:

well , not working with tarrifs yet, so commented out those lines at this mome

i also saw these once in my log file

2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production has unknown unit W
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption has unknown unit W
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_w has unknown unit W
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_exported_power_w has unknown unit W
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_hourly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_daily has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_weekly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_monthly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_imported_power_yearly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production_hourly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production_daily has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production_weekly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production_monthly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_production_yearly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption_hourly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption_daily has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption_weekly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption_monthly has unknown unit None
2021-08-17 14:12:00 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.solar_house_consumption_yearly has unknown unit None

Excuse my total lack of understanding mqtt as it the first time I am trying to use it. I have copied your example and it went through the check before restating HA and it went through without problems. What I donā€™t understand is where you get the servicelocation from which is the same for both consumption and solar production. Can you please point me in the right direction? Your help is very much appreciated! Thanks very much, Jos

you dont need mqtt, you can just use the 2 default entities that are being created locally
to know the servicelocation, if you want to use MQTT; download an tool , like mqtt explorer, subscribe to # channel, then you see info coming in, there you can see the service location

To use MQTT with Smappee, you have to:

  1. install MQTT with Home Assistant (I installed Mosquitto, it is a addon in HassOS)
  2. configure the smappee, see this link for a full description (just look at the MQTT part, not the RestApi):
    Can I get access to the data via MQTT? ā€“ Support
  3. Read the data in HA from your MQTT Broker (you can find your_service_location called UUID in the Smappee doc provided at step 2), these lines have to be included in sensors.yaml file:
- platform: mqtt
  state_topic: "servicelocation/your_service_location/realtime"
  name: "Smappee Power"
  unit_of_measurement: "W"
  value_template: "{{value_json.channelPowers[1].power}}" 

- platform: mqtt
  state_topic: "servicelocation/your_service_location/realtime"
  name: "Smappee Solar"
  unit_of_measurement: "W"
  value_template: "{{value_json.channelPowers[0].power}}" 

Let me know if you need more details or still have questions if you decide to use MQTTā€¦

Thank you for sharing!

So far so good. I just need to figure out how to create the attributes required by HA - Energy (last_reset, unit_of_measurement=kWh, etc.). Any idea?

@GoTTi74 If you follow the step I have documented above (see post #6 issued on Aug 16), you do not need to add anythingā€¦ Be careful, if an entity has not a value different than 0, it will not appear in the drop down listā€¦

@pergola.fabio @Trouble-51 @GoTTi74 I have corrected a bug in my post with the template.yaml file: you need to replace ā€œsmappeā€ by ā€œsmappeeā€ for the exported energy valueā€¦ The previous post has been corrected.

1 Like

Oh ok, maybe thatā€™s why it was still 0 ? :slight_smile: