Yes another one brand new to Home Assistant, but a semi seasoned user of OpenHAB converting over. I must say it was extremely easy to get started with and even get running with Alexa, which is one of the reasons for the conversion. That being said setting up the automation has proven to be frustrating. I basically need to start out with a single switch, a Sonoff updated with Tasmota controlled via MQTT, being able to parallel it’s status with another.
I have spent the better part of a day trying different configurations, reading articles and looking at examples to fall short. The switches all work fine independently with the UI and Alexa just need to start combining some for the effect.
A general example of on the things I tried would be:
This is just to give an idea of what I am trying to accomplish, though with this particular code I get a state error. Yet another example that is okay (Valid) with the check configuration is:
Please note that all code snippets etc should be formatted properly so we can see indentation etc. (YAML is a mixed blessing!). See the panel at the top of the page.
Well because that would be just too simple. LOL. I had just added the two over time and with OH2 and it was simple to do. Never even thought of doing that way but I will now.
Okay. Now I remember why I didn’t end up subscribing to the same topic, because if I publish to MQTT to activate the main switch the secondary, which is in a remote location,it will follow. But if the main switch is manually turned off/on the secondary does not follow suit. Never could figure that one out and basically it wasn’t previously necessary because in OH2 you can establish rules (aka automation) as follows
rule "Back Stair light"
when
Item BasementLights changed // to motion detected
then
if (BasementLights.state.toString == "ON") {
BackStair.sendCommand (ON)
}
if (BasementLights.state.toString == "OFF"){
BackStair.sendCommand (OFF)
}
I will add a couple of the example codes below, with the proper indentation, that I unsuccessfully tried just for a general reference in case someone has a solution. Or maybe someone knows why paralleling the topics via MQTT is not consistent. Would be happy with either solution.
I want to thank you all for sharing. I was able to finally find the magic combo that works, it was just a matter of learning the way HA codes. This is mainly for anyone in the future that may come across the same issue.
I am still not sure if or how Boolean works in HA, so that perhaps I can make this into a single automation, but this works perfectly fine whether I use the HA UI or manually trip the switch.
You are exactly correct. The whole point is to centralize as much as possible. If a switch would go bad for example I could pop a new one in an only have to change one item under “switch” in the configuration to match the name of the switch in the topic. True it’s not much easier than going to the switches UI and changing the topic but I like and want everything simply together as much as possible.
the one thing i noticed in your second automation in your last code example you posted above is that you have non-ascii (aka “fancy”) quote characters.
It’s a pretty common error during copy/paste and will totally screw things up since they aren’t real obvious in a standard text editor when they are there until you post them in the forum as you did.
And since you ultimately went with the second snippet with good quotes then it’s safe to say that was likely your problem all along.
You shouldn’t have to put a ‘from:’ line in your code to get it to work. unless there is some other possible state that it could be… but typically a binary is either on or off.
There are ways to get it into one automation but it would need templating an action service call to do it.
It doesn’t matter which switch I toggle manually or in the UI, the other one will follow.
The code could be shortened, but this way it’s easy to understand how it works.