I converted MQTT sensors from legacy to modern but no change in what I see in the Tasmota integration for this device. If I add a relay to that switch then the switch shows up in the integration with on/off controls but that is not what I want. I just want a sensor to display the state of the switch, which MQTT gives me. Is this not possible?
It does not appear possible to achieve what I want without adding a relay to ESP8266 Tasmota to match the switch. This would require then adding a sensor to HA based on the state of the switch to achieve what I want. 60/40 as to which is easier…
I think you are right that mqtt wont allow the complicated stuff. Set the simple sensor in Mqtt
value_template: ‘{{ value_json.Switch1 }}’
and do the more complicated value_template to the sensor you made under mqtt “coffeemaker” under the platform: template
--------
- platform: template
sensors:
usefulcoffeemaker:
friendly_name: usefulcoffee maker
value_template: >
{{ states('sensor.coffeemaker')more complicated stuff that mqtt sensor can't use }}
I had to use platform: template yesterday for one temp sensor in tasmota that needed value offset without affecting the other temp sensors
Thank you for your feedback but I’m afraid you’re still not getting it. The MQTT sensor I have is fine!
Rather than having to manually create a MQTT sensor though, I am trying to get it to show under the Tasmota auto discovered device as a sensor, not a switch. I can get a switch if I add a relay to the switch in the Tasmota configuration on the device, but I don’t want that. I just want a sensor…
Like this…
Again, I’m not sure it’s possible using Generic template in tasmota…
Sorry for the misunderstanding. I don’t think you can create the sensor in Tasmota even with rules. Have you considered ESPHOME. You can setup the pin as a binary sensor. Good Luck.
Time to start researching how ESPHome works I guess. This is the only clue I have to work from:
This helps…
Well that wasn’t as hard as I thought it would be!
Ungrounding D5 turns on the sensor…
esphome:
name: coffeemaker
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "<redacted>"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Coffeemaker Fallback Hotspot"
password: "<redacted>"
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: GPIO14 #D5
mode: INPUT_PULLUP
# inverted: True
name: "Coffeemaker Status"
# entity_category: config
id: coffeemaker_status
# Example configuration entry
output:
- platform: gpio
pin: GPIO12 #D6
id: output1
button:
- platform: output
name: "Make Coffee"
output: output1
duration: 1s
#switch:
# - platform: gpio
# pin:
# number: GPIO12 #D6
# id: relay
# inverted: true
# name: "Coffeemaker On/Off"
# icon: mdi:coffee-maker
# on_turn_on:
# - delay: 500ms
# - switch.turn_off: relay
*** Update
Now I just have to disassemble my KitchenAid Coffeemaker, remove the Sonoff inching relay w/120V:5V transformer and install this ESP8266 module with an additional connection to the power/brewing status LED.
Question: can I power the module via the 5V/GND pins instead of the USB connector???
Thanks! I had done it this way but your way makes better sense as the icon is everywhere then!
I added it, deleted the integration & re-added it and the icon says mdi-coffee-maker but the UI is not showing it…
binary_sensor:
- platform: gpio
pin:
number: GPIO14 #D5
mode: INPUT_PULLUP
name: "Coffeemaker Status"
id: coffeemaker_status
icon: mdi:coffee-maker
Neither does specifically changing the icon, even though it’s the same as was specified by ESPHome…
Bug in HA 2022.7.5? or ESPHome integration??
Do you have any binary_sensors?
Before:
After:
ESPHome:
binary_sensor:
- platform: gpio
pin:
number: GPIO14 #D5
mode: INPUT_PULLUP
# inverted: True
name: "Coffeemaker Status"
# entity_category: config
id: coffeemaker_status
# icon: mdi:coffee-maker
Uploaded config to device, deleted it from HA, restarted HA and new device discovered.
No change in behavior.
Specifying the icon in the entity does not display it in lovelace entities card:
Time for an HA bug report??
I let things be and HA sorted itself out over time…
I know this is old but I spent an hour trying to figure out why I couldn’t see my “Switch” type Tasmota entries in HA and I wanted to keep the Tasmota firmware. The reason is because discovery will only create a binary_sensor type sensor if:
- The switches are discoverable. This requires
SetOption114 ON
-
SwitchMode<x>
is not set to 0 (toggle). I set mine to 1 (follow), although 2 (invert follow) also works if the ON/OFF indicator is swapped. - (optional) The resulting HA sensors are named using
SwitchText<x>
This keys off the MQTT discovery message config.swc[]
. If your values are -1, that means SetOption114 is off and Tasmota is not publishing them. If they are set to 0, that means you’ll only get HA triggers defined for them. If they are set to 1, you get HA sensors for them. The names are in the discovery config.swn[]
.
I was struggling with this so matched your settings. I think I had to reboot the Tasmota to get HA to finally discover it.
Thank you.
After using
SetOption114 1
and
SwitchMode 1
and a reboot of the Tasmota device, the Switch1 became visible in Home Assistant.