Really struggling with manual configuration

I’ve three Tasmota Sonoff devices. When they’re auto-discovered, they work fine.

I want to know the Wifi signal strength of some of them, so I’ve added:

sensor:
  - platform: mqtt
    state_topic: "bridge/tele/state"
    name: "SocketRSSI"
    unit_of_measurement: "%"
    value_template: "{{ value_json.Wifi.RSSI }}"
    payload_available: "Online"
    payload_not_available: "Offline"

It didn’t work. The dev-state page tells me that for sensor.socketrssi the state is unavailable.

So, I’m thinking: “Maybe it’s because it was auto-discovered?” Can anyone confirm if this is relevant?

Or, can anyone indicate what stupid thing I’m doing?

What is it that causes the bridge/tele/state packet to be published, anyway? I don’t see this packet appear in the sonoff’s console.

Anyway, I took the plunge and setoption19 off on the S20, and tried to manually configure it. I’m going to have to do this at some point for some ESP8266 project ideas I have. May as well learn how to configure a device which I know is working.

I’ve added:

switch:
  - platform: mqtt
    name: "S20 Switch"
    state_topic: "S20_01/tele/STATE"
    value_template: "{{ value_json.POWER }}"
    command_topic: "S20_01/cmnd/POWER"
    availability_topic: "S20_01/tele/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

But when I go to the dev-state page, the entry for switch.s20_switch is showing as unavailable!

I’m losing my mind. I’m at a point were I’m ready to give you guys the URL and password for my installation and tell me what I’m doing wrong. I’m really not stupid, but some fundamental concept has clearly escaped me here.

I’ve actually stripped out eveything from my configuration.yaml file apart from the external broker config and this one switch. It’s just not working.

Any thoughts, please?

I would setup a mqtt client like mqttfx or mqtt lens and subscribe to the topics you want to check. Its really easy and I use it debug MQTT problems.

https://mqttfx.jensd.de/

btw, this is my Tasmosta setup, your topics look different.

light:
  - platform: mqtt
    name: Basement Light
    state_topic: "stat/basement_light/POWER"
    command_topic: "cmnd/basement_light/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

Did that. What would I subscribe to in order to watch the packets, please?

I read elsewhere that auto discovery swaps the first two parts of the state. You’ve got CMND/device/POWER, I’ve got device/CMND/POWER.

If I go to the dev-mqtt screen in HA, I can send a s20_01/cmnd/power packet (payload 1) which works. BUT only if the device was auto-discovered. If I try to add the switch manually, sending this packet doesn’t work.

Try something like this:

{{ states.sensor.sonoff1_2914_status.attributes.RSSI }}

With discovery, your topics etc are correct… Not sure why you are manually screwing with defining switches when you are using disovery but anyway…

That above template gives me the RSSI

You can subscribe to something like this

S20_01/#

the # will give you all everything under S20_01/

This is what I use:

value_template: "{{value_json['Wifi'].RSSI }}"

1 Like

Because …

…and…

I understand JSON sufficiently to grasp that this should also work for me. Tell me: in your case, is that device auto-discovered, or completely manually added?

Manually added.

This is absolutely messing with my head. I’ve done that. It reports all the mesages when the switch is auto-configured. Works perfectly.

My two questions are: do I need to manually configure in order to retrieve, for example the device’s Wifi signal strength, and, why does my manually configured device show up in teh entity list as “unavailable”?

Is your device a Sonofff? Tasmotised? Could I get a look at how you’ve manually added the switch as a switch, please?

Yes, yes and yes respectively:

switches.yaml

- platform: mqtt
  name: "Dining Heater North"
  state_topic: "stat/sonoff_dining_heater_north/POWER"
  command_topic: "cmnd/sonoff_dining_heater_north/POWER"
  availability_topic: "tele/sonoff_dining_heater_north/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: false

sensors.yaml

- platform: mqtt
  name: "Dining Heater North Energy Today"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Today"] }}'
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "Dining Heater North Energy Yesterday"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Yesterday"] }}'
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "Dining Heater North Energy Total"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Total"] }}'
  unit_of_measurement: "kWh"
- platform: mqtt
  name: "Dining Heater North Power"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Power"] }}'
  unit_of_measurement: "W"
- platform: mqtt
  name: "Dining Heater North Voltage"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Voltage"] }}'
  unit_of_measurement: "V"
- platform: mqtt
  name: "Dining Heater North Current"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Current"] }}'
  unit_of_measurement: "A"
- platform: mqtt
  name: "Dining Heater North Power Factor"
  state_topic: "tele/sonoff_dining_heater_north/SENSOR"
  value_template: '{{ value_json["ENERGY"]["Factor"] }}'
  unit_of_measurement: "PF"
- platform: mqtt
  state_topic: "tele/sonoff_dining_heater_north/STATE"
  name: "Dining Heater North Wifi Signal"
  unit_of_measurement: "%"
  value_template: "{{value_json['Wifi'].RSSI }}"
  availability_topic: "tele/sonoff_dining_heater_north/LWT"
  payload_available: "Online"
  payload_not_available: "Offline"

Cool. So, I think, for me, the basic bit is the switch which translates as:

switch:
  - platform: mqtt
    name: "MySwitch"
    state_topic: "stat/S20_01/POWER"
    command_topic: "cmnd/S20_01/POWER"
    availability_topic: "tele/S20_01/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

Can you confirm if I’m being a thickie? Config passes LINT check. The entity switch.myswitch appears in HA’s dev-state window BUT its status is “unavailable.” I can go the the HA dev-mqtt window and send a s20_01/cmnd/power 1 packet and it works.

Any clues what might be going on, please?

What version of Tasmota do you run on your S20?

I’m using 6.2.1

If you are using the newer firmware the topics have changed:

6.4.1.
Irritating as it is trying to talk in a protocl which is ever-changing, i had originally followed the idiot’s guide to 6.3.0.17. For me, that translates as:

switch:
  - platform: mqtt
    name: "MySwitch"
    state_topic: "tele/S20_01/POWER"
    command_topic: "cmnd/S20_01/POWER"
    availability_topic: "tele/S20_01/LWT"
    value_template: "{{ value_json.POWER }}"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

But with this, even though the entity switch.myswitch appears in HA’s dev-state window, its status is still “unavailable.”

My head really is about to explode.

Please format your pasted code correctly. You’ve made enough posts to know this. I shouldn’t have to remind you.

Look at the example link I posted again. According to that wiki your state topic is incorrect.

Yours:

state_topic: “tele/S20_01/POWER”

Should be :

state_topic: "tele/S20_01/STATE"

Apologies for hitting blockquote instead of preformatted text really late at night and seriously frustrated.

Typo on my part. Now reads:

switch:
  - platform: mqtt
    name: "S20_01"
    state_topic: "tele/S20_01/state"
    command_topic: "cmnd/S20_01/POWER"
    availability_topic: "tele/S20_01/LWT"
    value_template: "{{ value_json.POWER }}"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

But switch.myswitch still reads as unavailable on the states page. I’ve reloaded, rebooted, ctrl-F5’d. I have only the one switch: section…

That’s probably because the switch entity id is now going to be switch.s20_01 as you have changed the config:

switch:
  - platform: mqtt 
    name: "S20_01" ###<----- This will create the switch entity id

Check your developer tools states menu for the actual switch entity id.