Shelly 2.5 as pulse relay to switch existing dimmer

I have a dimmer (Jung 1731DD) which is mainly operated manually, but I would like to switch this dimmer on in case I’m not at home. This dimmer can be switched on/off using a pulse signal (relay on for 100ms). To make this work I have a Shelly 2.5.:

  • One port is used as pulse relay (shelly is configured to automatically switch off after 0.1s).
  • the other port of the shelly (always on) to feed the dimmer and measure the power consumption of the dimmer

The shelly 2.5 is controlled via MQTT.
Currently I have created the folowing 2 MQTT entities in configuration.yaml.

sensor:
 - platform: mqtt
   name: "Vermogen lamp eetkamer"
   unique_id: "vermogen_lamp_eetkamer"
   qos: 1
   expire_after: 86400
   device_class: power
   unit_of_measurement: 'W'
   icon: mdi:lightning-bolt
   state_topic: "shellies/shellyswitch25-eetkamer/relay/0/power"
light:
- platform: mqtt
  name: "Eetkamer"
  unique_id: "Eetkamer"
  payload_on: "on"
  payload_off: "off"
  qos: 1
  icon: mdi:power
  state_topic: "shellies/shellyswitch25-eetkamer/relay/1"
  command_topic: "shellies/shellyswitch25-eetkamer/relay/1/command"
  json_attributes_topic: "shellies/shellyswitch25-eetkamer/info"

When the light entity is toggled via the lovelace interface it switches on and because the shelly switches of after 0,1s the light entity it is automatically also switched off again.
Another problem is that when providing a pulse one does not know whether the pulse toggled the dimmer to on or off.

Now I would like to make an entity that sends payload: “on” to toggle the dimmer and use the power consumption reading to determine whether the dimmer is on or off. How can I do that?

1 Like

Does this help?

Thanks for your answer. It brought me to MQTT Light - Home Assistant (home-assistant.io).

I think I have to have something like this

mqtt:
  light:
    - name: "Eetkamer1"
      state_topic: "shellies/shellyswitch25-eetkamer/relay/0/power"
      command_topic: "shellies/shellyswitch25-eetkamer/relay/1/command"
      payload_on: "on"
      payload_off: "off"
      qos: 1
      optimistic: true
      state_value_template: >-
        {% value_json.state|as_float >3 %}
          on
        {% else %}
          off
        {% endif %}

But there is something wrong as I get the following error message when I click “check configuration”

Invalid config for [mqtt]: invalid template (TemplateSyntaxError: Encountered unknown tag 'value_json'.) for dictionary value @ data['mqtt']['light'][0]['state_value_template']. Got '{% value_json.state|as_float >3 %}\n on\n{% else %}\n off\n{% endif %}'.

Everything is working perfectly now. Below my configuration:

Configuration of the shelly itself to create a pulse contact (only on for 0.1s)


Though the time setting is colored red it does work properly. The other switch port (relay/0) is configured to be always switched on to ensure the dimmer has power and the power consumption of the dimmer is measured.

In configuration.yaml

mqtt:
  light:
    - schema: template
      name: "Eetkamer"
      unique_id: "Verlichting_eetkamertafel"
      command_topic: "shellies/shellyswitch25-eetkamer/relay/1/command"
      command_on_template: "on" 
      command_off_template: "on" 
      qos: 2 #essential to ensure that the message is only send once. qos: 1 might lead to multiple triggers sent to the shelly sometimes leading that toggle is not effective
  #      optimistic: true  # On itself usefull as it will instantly toggle the status and waits for the state_template to confirm, but when activated the toggle is replaced by 2 icons indicating status on and off
      state_topic: "shellies/shellyswitch25-eetkamer/relay/0/power"
      state_template: "{{ iif(value|int >= 3, 'on', 'off') }}" # When the shelly reads a power consumption of more than 3Watt it is considered on

Not essential and only for monitoring purposes I’ve also added 2 sensors that report the power (W) and energy (kWh) consumption. Therefore you have to add the configuration below to the configuration above.

sensor:
  - name: "Vermogen lamp eetkamer"
    unique_id: "vermogen_lamp_eetkamer"
    qos: 1
    expire_after: 86400
    state_class: measurement
    device_class: power
    unit_of_measurement: 'W'
    state_topic: "shellies/shellyswitch25-eetkamer/relay/0/power"
  - name: "Energieverbruik lamp eetkamer"
    unique_id: "Energieverbruik_lamp_eetkamer"
    qos: 1
    expire_after: 86400
    state_class: total_increasing
    device_class: energy
    unit_of_measurement: 'kWh'
    state_topic: "shellies/shellyswitch25-eetkamer/relay/0/energy"
    value_template: "{{ (value|float/60/1000)|round(2) }}" #shelly report energy consumption in Wminute an therefore needs to be divided by 60 and 1000 to convert into kWh

@Vliegeraar
Were you ever able to also control the dimming functionality in your scenario?

I have the same scenario but with a Niko 33-700 dimmer at the switch board and Niko pulse switches in the room.

I currently have it working (in an ugly test setup at the switch board) to turn it on & off with a shelly plus 1 mini PM but I can not get it to dim via the shelly.
Dimming with the switch still works.

To be honest I’m not sure if I got the right device or not but ideally i want to get a shelly behind the switch to just replicate the pulses that the switch is sending and integrate it in HA. I have a shelly dimmer 2 here as well but as the dimmer in the switch board needs to do the actual dimming this also does not seem like the right solution to me.

The switch currently only has a live wire and the switch wire (no neutral wire).

Would appreciate any input you have as I find very little information on this kind of setup around the web.

I only use this setup to toggle the dumb dimmer on/off. The reason the pulse is only 0.1s is because if it will take longer, the dimmer will start cycling through higher and lower light intensity. But I have no clue where the dimmer is in its cycle and consequentially, I can’t set the the dimmer to a desired intensity.