Adding support for Smappee

Interesting ideas indeed

Hmm, some strang readings, i have 3 phase
if i power off/on the device, seems there is always 1 phase not displaying correct results
i notice this because
i have an induction
when i turn in one plate, it goes to 3 KW on power mode => seems ok
when i turn on anothre plate , probably another phase => it goes from 400 to 100 W ??
fase 2 + fase 3 was used
rebooted the smappee , did same test again, now i see good results, but go up to 3 KW if i turn on the plates
but now fase 1 , i have a microserver, if i turn it on, i see again negative results ??? how can that be?

is it possible to see here negative values? seems wrong to me?

edit; alle arrows are correct on clamps, i rechecked 10 times :slight_smile:

@Dizzyikea or some else

i have smappee first gen running on ha, with local detection , so not MQTT
i only have 2 sensors… (totalconsumption /total power) …if i enable mqtt, will i have more stuff? since 2021.8 there is an energy funcion
would be nice to see more sensors and/or detected devices?

Sorry for using this topic, but I’m not a programming wizard and need some help.
I’ve a smappee genius which monitors my 3 phase home, solar, heatpump, heatpump backup resistor and my smart car charger to optimise solar consumption.
I have also installed a Smappee Output module to control the heatpump. (Output Module)

With 1 output I can completely block the heatpump, with the 2nd I can enable/disable comfort temperature for the domestic hot water. I currently only use the 2nd. When there’s enough sun, the 300L boiler is heated to 65°C, when not enough sun is available it is only heated to about 45°C

I was hoping to integrate this module into HA as well, but I’m a bit struggling. It combines the 2 outputs into a state. If I look up the value of the plug in MQTT Explorer the value/state of the sensor is STATE0 or STATE1 or STATE2… It isn’t simply an ON or OFF status.
2023-01-30 15_45_44-MQTT Explorer

How Can I integrate this into HA?

with a select mqtt maybe? there you can define multiple options, instead of like a switch with only on/off

That helped a bit.
I can now read the status of the plug in HA.
But it is of course STATE0, STATE1…
Is there an option to give these states a better name that is more understandable?

maybe you can use a template switch/button/light … based on some state it will be on/off ?

This is the code I have now:

select:
    - state_topic: "servicelocation/UUID/plug/1/state"
      command_topic: "servicelocation/UUID/plug/1/state"
      name: "Status Warmtepomp"
      value_template: "{{value_json.value}}"
      options:
        - "STATE0"
        - "STATE1"
        - "STATE2"
        - "STATE3"
      command_template: >
        { 
          "value" : "STATE1", 
          "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
        }

I have this drop down menu now in my overview.
Is it possible to change those names to something more meaningfull?
And how can you make it to sent the state you select? As you can see in the code, I now only sent STATE1, If I now select another status, I can see that the status changes to STATE1 and stays there. But in the SMAPPEE app the status isn’t changing for some reason…
image

seems changing names is/was a feature request

for sending commands based on what you select, you need to create automations
see in the guide for the select here:

This is again completely different coding…
I’m at a loss now. Not sure how to implement this…

Maybe you can try this.
Use a normal input_select

input_select:
  status_warmtepomp:
    name: "Status Warmtepomp"
    options:
      - "aaaa"
      - "bbbb"
      - "cccc"
      - "dddd"

And try this automation

alias: Status warmtepomp
trigger:
  - platform: state
    entity_id: input_select.status_warmtepomp
action:
  - service: mqtt.publish
    data:
      topic: servicelocation/UUID/plug/1/state
      payload_template: >
        {% if states('input_select.status_warmtepomp') == 'aaaa' %}
          { 
            "value" : "STATE0", 
            "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
          }
        {% elif states('input_select.status_warmtepomp') == 'bbbb' %}
          { 
            "value" : "STATE1", 
            "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
          }
        {% elif states('input_select.status_warmtepomp') == 'cccc' %}
          { 
            "value" : "STATE2", 
            "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
          }
        {% else %}
          { 
            "value" : "STATE3", 
            "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
          }
        {% endif %}

Or try this one

select:
  - name: "Status Warmtepomp"
    options:
      - "aaaa"
      - "bbbb"
      - "cccc"
      - "dddd"
    state_topic: "servicelocation/UUID/plug/1/state"
    value_template: >
      {% if value_json.value ==  "STATE0" %} aaaa
      {% elif value_json.value == "STATE1" %} bbbb
      {% elif value_json.value == "STATE2" %} cccc
      {% elif value_json.value == "STATE3" %} dddd
      {% endif %}
    command_topic: "servicelocation/UUID/plug/1/state"
    command_template: >
      {% set value_map = {
            "aaaa": STATE0,
            "bbbb": STATE1,
            "cccc": STATE2,
            "dddd": STATE3,
          }
      %}
      { 
            "value" : {{ value_map[value] }}, 
            "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
          }
    optimistic: false
    qos: 0
    retain: true

Found this topic MQTT Select won't publish the new selected value

Now, I’ve got this:

input_select.yaml

status_warmtepomp:
  name: "Status Warmtepomp"
  options:
    - "Warmtepomp Vrij + Weerstand Geblokkeerd"
    - "Wartmepomp + Weerstand Vrij (Daluren)"
    - "Warmtepomp + Weerstand Geblokkeerd"
    - "DO NOT USE"

automations.yaml

[
# Automation.
# This automation script runs when a value is received via MQTT on retained topic: thermostatMode
# It sets the value selector on the GUI. This selector also had its own automation when the value is changed.
- alias: "Set Status Warmtepomp"
  trigger:
    platform: mqtt
    topic: "servicelocation/UUID/plug/1/state"
   # entity_id: input_select.thermostat_mode
  action:
    service: input_select.select_option
    target:
      entity_id: input_select.status_warmtepomp
    data:
      option: >
        {% if states('value_json.value') == 'STATE0' %}
          { 
            "Warmtepomp Vrij + Weerstand Geblokkeerd"
          }
        {% elif states('value_json.value') == 'STATE1' %}
          { 
            "Wartmepomp + Weerstand Vrij (Daluren)"
          }
        {% elif states('value_json.value') == 'STATE2' %}
          { 
            "Warmtepomp + Weerstand Geblokkeerd"
          }
        {% else %}
          { 
            "DO NOT USE"
          }
        {% endif %}

 # This automation script runs when the thermostat mode selector is changed.
 # It publishes its value to the same MQTT topic it is also subscribed to.
 
- alias: "Status warmtepomp"
  trigger:
    - platform: state
      entity_id: input_select.status_warmtepomp
  action:
    - service: mqtt.publish
      data:
        topic: "servicelocation/UUID/plug/1/state"
        payload_template: >
          {% if states('input_select.status_warmtepomp') == 'Warmtepomp Vrij + Weerstand Geblokkeerd' %}
            { 
              "value" : "STATE0", 
              "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
            }
          {% elif states('input_select.status_warmtepomp') == 'Wartmepomp + Weerstand Vrij (Daluren)' %}
            { 
              "value" : "STATE1", 
              "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
            }
          {% elif states('input_select.status_warmtepomp') == 'Warmtepomp + Weerstand Geblokkeerd' %}
            { 
              "value" : "STATE2", 
              "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
            }
          {% else %}
            { 
              "value" : "STATE3", 
              "since" : {{ (as_timestamp(now()) * 1000) | round(0)}}
            }
          {% endif %}
]

But in the file editor I get an error:

missed comma between flow collection entries (5:1)

2 | # Automation.
3 | # This automation script runs wh …
4 | # It sets the value selector on …
5 | - alias: “Set Status Warmtepomp”
-----^
6 | trigger:
7 | platform: mqtt

Have you tried the mqtt_select?

It works now!
The command topic was also wrong, instead of state, it needed to be setstate…
Below the code that works for me, now!
I can now also see in the Smappee app the state changes when I change it in HA.

select:
  - name: "Status Warmtepomp"
    options:
      - "Warmtepomp Vrij + Weerstand Geblokkeerd"
      - "Wartmepomp + Weerstand Vrij (Daluren)"
      - "Warmtepomp + Weerstand Geblokkeerd"
      - "DO NOT USE"
    state_topic: "servicelocation/UUID/plug/1/state"
    value_template: >
      {% if value_json.value ==  "STATE0" %} Warmtepomp Vrij + Weerstand Geblokkeerd
      {% elif value_json.value == "STATE1" %} Wartmepomp + Weerstand Vrij (Daluren)
      {% elif value_json.value == "STATE2" %} Warmtepomp + Weerstand Geblokkeerd
      {% elif value_json.value == "STATE3" %} DO NOT USE
      {% endif %}
    command_topic: "servicelocation/UUID/plug/1/setstate"
    command_template: >
      {% set value_map = {
            "Warmtepomp Vrij + Weerstand Geblokkeerd": "STATE0",
            "Wartmepomp + Weerstand Vrij (Daluren)": "STATE1",
            "Warmtepomp + Weerstand Geblokkeerd": "STATE2",
            "DO NOT USE": "STATE3",
          }
      %}
      {"value":"{{ value_map[value] }}","since":{{ (as_timestamp(now()) * 1000) | round(0)}}}
    optimistic: false
    qos: 0
    retain: true

Many thanks for the help Giel!!!
I wouldn’t have managed this without your help.

2 Likes

Just received my new smappee solar, it needed a manually firmware update on port 8022, even iphone was not possible to update firmware…

Anyway, just to know, the smappee API cloud is FREE again, you can receive new credentials again…
Now easy to implement water/gas instead of using mqtt

Hi there, HA newby… I have a smappee energie monitor but i just cant get the installation on HA right. I’m in the smapee monitor, but i have to input a MQTT local broker. I have mosquitto running in HA, works fine with Z2M,
but what is my mqtt local broker?
or what about that API i’ve been reading about?

You must configure your mosquitto instance, and you can later use the values published in Home Assistant.

Sorry but i’ve lost u at mosquitto instance.
My mosquitto broker is running. I have a hostname. But i don’t have an ip adress.

What I want to say is that you must configure in the Smappee admin page, in the mqtt data, your Home Assistant mosquitto information (host, port, etc.).
Use for example https://mqtt-explorer.com/ to try to connect to your homeassistant mosquitto instance and when you are able to do it, put the data in the smappee portal, similar to this: