Home Assistant : Q&A, Tips & Tricks, Your Configs

MattRoy

Well-Known Member
Joined
Jan 10, 2011
Messages
322
Why not a mqtt sensor? It doesnt need to be a switch. Sensor is all you need to know the state.

Actually why not just a cover? A cover is what you want. It will look like a gate in HA and work like a gate and you can open/close on the switch and see state on the 2nd part.
I second this. I use a cover for garage doors and front gate with Sonoff SVs flashed with ESPHome. Having the ability to both show the state and interact with them in one entity in HA is great.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
39,641
Found this rather amusing, bought this smart wall panel heater for the baby room
d579cfc627b64c44f7000397a4370dc3.jpg
daed36beec6625a66e9a4a0ed2dc490b.jpg
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,515
Found this rather amusing, bought this smart wall panel heater for the baby room
d579cfc627b64c44f7000397a4370dc3.jpg
daed36beec6625a66e9a4a0ed2dc490b.jpg
model name is at least smart.

That said, it doesn't look like the wiring is there, what is your findings after opening the sonoff?
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
@n00bster

See this:
YAML:
cover:
  # Front property gate
  - platform: mqtt
    device_class: gate
    state_topic: "stat/front-gate/POWER2"              #SwitchTopic Enabled
    command_topic: "cmnd/front-gate/POWER1"
    availability_topic: "tele/front-gate/LWT"
    name: "Front Gate"
    qos: 0
    retain: false
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
yes this is what I I want I am just struggling with the config on the Tasmota. All guides point to making GPIO14 a switch. but i cant get the unit to read anything I do to GPIO14. I have a door contact on it and I see no info in console when opening or closing it. There is no sensor option on GPIO14 selection.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,515
yes this is what I I want I am just struggling with the config on the Tasmota. All guides point to making GPIO14 a switch. but i cant get the unit to read anything I do to GPIO14. I have a door contact on it and I see no info in console when opening or closing it. There is no sensor option on GPIO14 selection.
The GPIO14 set to switch2 in configuration (on tasmota).

When configured correctly, you will see 2 power switches on the tasmota screen. This is required. 1st is the actual switch, 2nd is showing gpio14 state.

If you test the gate opening closing, or the sensor for that matter, you need to see the switch on the tasmota main screen changing between on/off (thats how you test that it works). If this is not working, your reed switch is not working how it is connected right now.

I think this is what I used to configure my sonoff sv:
Code:
PulseTime1 10
Switchretain 1
Powerretain 1
switchmode1 0
switchmode2 2
switchtopic2 2

the notes:
Switchretain 1 -- 0 = disable use of MQTT retain flag (default) 1 = enable MQTT retain flag on switch press
Powerretain 1 -- MQTT power retain state, 0 / off = disable MQTT power retain on status update (default) 1 / on = enable MQTT power retain on status update
PulseTime1 10 -- After this amount of time, the power will be turned OFF 113 = 13 seconds
switchmode1 0 -- 0 = toggle (default) 1 = follow (0 = off, 1 = on) 2 = inverted follow (0 = on, 1 = off)
switchmode2 2
switchtopic2 garagestate -- = set MQTT switch topic
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,603
what I am not sure about is the state_topic (POWER2) and command topic (POWER)? that @SauRoNZA has in his posted code.

state_topic is when you want the state of this cover to show that of the POWER2 topic correct? Meaning State of this cover = state of the POWER2

I want it to function on its own since it is a door contact it has its own topic of POWER, that is setup in the tasmota console.

so my code should be right?

My advise is watch your console and use the data from there to build your config rather than going by what you expect from the internet.

But why do you have two relays in the first place anyway?

The console will show you exactly what the data is being generated and then you can just populate HA template with that.

And yes the name is just the randomised name assigned when you use Tasmota auto-config for HA.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,603
@n00bster

See this:
YAML:
cover:
  # Front property gate
  - platform: mqtt
    device_class: gate
    state_topic: "stat/front-gate/POWER2"              #SwitchTopic Enabled
    command_topic: "cmnd/front-gate/POWER1"
    availability_topic: "tele/front-gate/LWT"
    name: "Front Gate"
    qos: 0
    retain: false
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
Interesting you have device_class in there, I wonder when that was added and if it would sort out my need to specifically override it for HomeKit elsewhere.

Can't remember why I didn't use stat and went for cmnd, there was a reason that made it just not work.
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
39,641
model name is at least smart.

That said, it doesn't look like the wiring is there, what is your findings after opening the sonoff?
It suddenly came with Tasmota. :p

The wiring is fine on the inside - a little difficult to get to, they've wired it so you can turn it on using either the heater switch, or using the Sonoff Basic.

Much better :)
Capture.PNG
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,515
Interesting you have device_class in there, I wonder when that was added and if it would sort out my need to specifically override it for HomeKit elsewhere.

Can't remember why I didn't use stat and went for cmnd, there was a reason that made it just not work.
No idea, all it does for me, is change the look of the image in HA.

Screenshot 2022-05-23 at 14.43.59.png
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,603
Found this rather amusing, bought this smart wall panel heater for the baby room
d579cfc627b64c44f7000397a4370dc3.jpg
daed36beec6625a66e9a4a0ed2dc490b.jpg
Missed opportunity not to have a thermostat built in.

Then again a thermostat there would read so very wrong it would be useless.

I'm surprised it doesn't melt.

It's a nice neat solution and I would definitely replace mine with those when I have separate temperature readings in each room.

Right now I have TH10/16's on my panels and they do the job but it's ****ing ugly and hard to hide.

****

Also pro tip - Buy some foil sellotape and line the wall behind the panels with it...makes a HUGE difference radiating into the room instead of the bloody wall behind it.

Near invisible, would only notice if you go looking for it.

1673901e73cab3e9b18fb23d151c7fbb.jpg
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
39,641
Missed opportunity not to have a thermostat built in.

Then again a thermostat there would read so very wrong it would be useless.

I'm surprised it doesn't melt.

It's a nice neat solution and I would definitely replace mine with those when I have separate temperature readings in each room.

Right now I have TH10/16's on my panels and they do the job but it's ****ing ugly and hard to hide.

****

Also pro tip - Buy some foil sellotape and line the wall behind the panels with it...makes a HUGE difference radiating into the room instead of the bloody wall behind it.

Near invisible, would only notice if you go looking for it.

1673901e73cab3e9b18fb23d151c7fbb.jpg
Thanks for the tip - waiting for wife to get home to decide on where it must go - so there's still time. Wonder if I can just duct tape normal foil to the wall

I fortunately have a external thermostat in the room - so nicely setup in Home-assistant automatically now via the climate integration - I just set the temperature I want and HA does the rest.
 

Mzezman

Expert Member
Joined
Nov 13, 2021
Messages
1,255
Thanks for the tip - waiting for wife to get home to decide on where it must go - so there's still time. Wonder if I can just duct tape normal foil to the wall

I fortunately have a external thermostat in the room - so nicely setup in Home-assistant automatically now via the climate integration - I just set the temperature I want and HA does the rest.
HA is awesome for things like this - use state / value of 1 entity / sensor and do something with another
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,603
Thanks for the tip - waiting for wife to get home to decide on where it must go - so there's still time. Wonder if I can just duct tape normal foil to the wall

I fortunately have a external thermostat in the room - so nicely setup in Home-assistant automatically now via the climate integration - I just set the temperature I want and HA does the rest.
it will probably become a very sticky mess in time.

Remember don't put these on external walls.

Have the same via Dualmode_Mode Generic Thermostat and Climate controls yeah.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
44,603
okay so then it needs to be a switch because I do not want to combine it.

I have already decoupled the GPIO14 (switch 2) on the tasmota console.

I now just need to get the switch into HA.

I’m not sure what you are trying to do but you seem to be complicating everything for no good reason.

Why wouldn’t you combine it?

Why don’t you want to use the cover mechanism?
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
My advise is watch your console and use the data from there to build your config rather than going by what you expect from the internet.

But why do you have two relays in the first place anyway?

The console will show you exactly what the data is being generated and then you can just populate HA template with that.

And yes the name is just the randomised name assigned when you use Tasmota auto-config for HA.
I have 2 relays because I want to control Open for car and Open for pedestrian. then I just need the switch to reflect the status of both if they are open or close.

the issue I had which I finally figured out is that my switch states were not showing in console so i could need see what the topic was correctly. There was option code I had to enable to see it.

@Tinuva please can you help me I need 2 Buttons to show for the 2 relays and then use the switch 2for the status.

topic for relay 1 = stat/gate/POWER1
topic for relay 2 = stat/gate/POWER2
topic for switch 2 = cmnd/gatestatus/POWER2

I am playing around with your code you sent now will see if i can come right on my own.
 
Last edited:

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
11,515
I have 2 relays because I want to control Open for car and Open for pedestrian. then I just need the switch to reflect the status of both if they are open or close.

the issue I had which I finally figured out is that my switch states were not showing in console so i could need see what the topic was correctly. There was option code I had to enable to see it.

@Tinuva please can you help me I need 2 Buttons to show for the 2 relays and then use the switch 2for the status.

topic for relay 1 = stat/gate/POWER1
topic for relay 2 = stat/gate/POWER2
topic for switch 2 = cmnd/gatestatus/POWER2

I am playing around with your code you sent now will see if i can come right on my own.
What device is this. If it has 2 relays, you need to have it configured as if it has 3 switches in tasmota.
 

n00bster

Well-Known Member
Joined
Nov 25, 2008
Messages
170
What device is this. If it has 2 relays, you need to have it configured as if it has 3 switches in tasmota.
yes the switches are working. I can trigger both switches in Tasmota UI and on the Tasmota integration in HA I cant see the status switch though how do I add that in HA? in the integration Tasmota cant see it there.
this is what I can see in the integration of HA. Just need to add it to a cover card that will show status of both using the Switch2

1653329927559.png

got it working with the below cover. Now I just need a better looking card. Is there a way to get the whole card change color depending on state?

Code:
cover:
  - platform: mqtt
    name: "Gate 1"
    state_topic: cmnd/gatestatus/POWER2
    command_topic: cmnd/gate/Power1
    availability_topic: tele/gate/LWT
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "OFF"
    state_closed: "ON"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0
    retain: false
  - platform: mqtt
    name: "Gate 2"
    state_topic: cmnd/gatestatus/POWER2
    command_topic: cmnd/gate/Power2
    availability_topic: tele/gate/LWT
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "OFF"
    state_closed: "ON"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0
    retain: false

1653336115575.png
 
Last edited:
Top