Configure Shelly 2PM for mqtt light

Hi to all,
I have a Shelly 1 PM that work fine with this mqtt switch configuration:

    - name: "Shelly 1PM condizionatori - Switch"
      state_topic: "shellies/shelly1pm-consumi-condizionatori/status/switch:0"
      value_template: "{{ value_json.output }}"
      state_on: true
      state_off: false
      command_topic: "shellies/shelly1pm-consumi-condizionatori/rpc"
      payload_on: '{"id":1, "src": "homeassistant", "method": "Switch.Set", "params":{"id":0,"on":true}}'
      payload_off: '{"id":1, "src": "homeassistant", "method": "Switch.Set", "params":{"id":0,"on":false}}'
      optimistic: false
      qos: 0  

Now I’m trying to configure a Shelly 2PM with a mqtt light configuration like this:

  - name: "Luce penisola"
    state_topic: "shellies/shelly25_cucina/status/switch:0"
    state_value_template: "{{ value_json.output }}"
    command_topic: "shellies/shelly25_cucina/rpc"
    payload_on: '{"id":1, "src": "homeassistant", "method": "Switch.Set", "params":{"id":0,"on":true}}'
    payload_off: '{"id":1, "src": "homeassistant", "method": "Switch.Set", "params":{"id":0,"on":false}}'
    optimistic: false
    qos: 0
    retain: false

I tried a lot but nothig. Light status of litgh is always “unknown”.

Someone can help me please?

your topic for 2pm suggests it’s shelly2.5.
Are you sure you are looking at right topic?

Yes, it’a only the old topic name.
I’m replacing an old shelly 2.5 with a new shelly 2pm.
This is the output of MQTT Explorer:

Thank you

I found the solution.

This is the yaml configuration of mqtt light:

  - name: "Luce penisola"
    command_topic: "shellies/shelly25_cucina/command/switch:0"
    payload_on: 'on'
    payload_off: 'off'
    state_topic: "shellies/shelly25_cucina/status/switch:0"
    state_value_template: "{{ 'off' if value_json.output == false else 'on' }}"
    availability_topic: "shellies/shelly25_cucina/online"
    payload_available: 'true'
    payload_not_available: 'false'
    optimistic: false
    qos: 0
    retain: false

and this is the Shelly2PM mqtt settings:

1 Like