-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple switchtopics? #88
Comments
I did add a number after the defined switchtopic so that should make identification possible. |
as in switchtopic<x> (similar to power<x>)?
|
I thought soo but after looking at the code it seems to do:
BTW how did you select more than one switch as in the default code I do not allow more than one switches? |
@arendst does the firmware allow multi switch like below? I just saw your reply, may I know why limit swtich number? |
On Mon, 20 Feb 2017, Theo Arends wrote:
BTW how did you select more than one switch as in the default code I do not allow more than one switches?
I haven't yet, I'm wanting to do so. For example, the sonoff sv has a 9 pin
header on it that exposes 3 GPIOs, I want to hook switches to all three to
control other things in the house.
|
I've just hit this limitation by wanting to connect 2 PIR sensors (facing in opposite directions). Is this something that can be achieved? i.e. the Idea being that these PIR's switch on lights for different areas via MQTT. |
do you mind share how do you do it? |
Did some rewrite for the switches. It now supports four of them but beware of the functionality: without switchtopic set it tries to control the relays depending on the amount of relays present. Best usage is setting a switchtopic and use MQTT to react. SwitchMode1 to SwitchMode4 is also available. Implemented in version 3.9.21 just released |
it works, Thanks for your great works, just one question, |
@hamwong You say it works, but it does not work for me. Can you share any info on what you had to do to make this work? |
U first need to set 2 switch as difference switch |
You also can define each switch reaction by switchmode1 by check status |
you only have one power because you would only have one relay (and I'm not sure
tasmota supports zero relays)
what you would need to do is
switchmode1 mode
switchmode2 mode
where mode is 0-4
search for switchmode on the command page
https://github.com/arendst/Sonoff-Tasmota/wiki/Commands
David Lang
|
oops, I answered switchmode not switchtopic, but the basis is the same, as hamwong correctly answered. |
Thank you! it FINALLY works! I SWEAR TO GOD I had done just this in the past.. Perhaps I had messed up something the last 20 times I tried it but I can't imagine what :/ |
Doesn't matter, human mistake happens all the time as computer never go wrong, if it did, that's human mistake XD |
Wait.. something is wrong..
I'm getting two switches on the one topic.. Even though I set it up with:
The tvarea topic is never triggered. |
Wait.. something is wrong..
```
19:23:04 MQTT: cmnd/stairs/POWER1 = ON
19:23:16 MQTT: cmnd/stairs/POWER2 = OFF
19:23:19 MQTT: cmnd/stairs/POWER2 = ON
19:23:47 MQTT: cmnd/stairs/POWER1 = OFF
19:24:14 MQTT: cmnd/stairs/POWER2 = OFF
19:24:17 MQTT: cmnd/stairs/POWER2 = ON
```
I'm getting two switches on the one topic..
Even though I set it up with:
```
19:09:46 CMND: switchtopic2 tvarea
19:09:46 MQTT: stat/upstairs/RESULT = {"SwitchTopic":"tvarea"}
19:10:00 CMND: switchtopic1 stairs
19:10:00 MQTT: stat/upstairs/RESULT = {"SwitchTopic":"stairs"}
```
The tvarea topic is never triggered.
Ok, that's not what I expected to have happen, but that is separating the two
switches so that you can handle them separately on the server.
@arendst, is this working as expected and we have been misunderstanding
swtichtopic<n>? or is this a bug?
David Lang
|
Fact: There is but ONE switchtopic available that can be addressed by
So the difference in switches is the number after POWER<x> as I tried to explain in the fourth entry of this issue (where it failed to note the switchtopic due to my mistake of using < and >). I must say you all came a long way after 17 days ;-) BTW do not start to complain about numbers after switchtopic either. It's not a bug, it's a feature of no use. |
Well I got POWER1 and POWER2 to appear. It wasn't appearing before I used the switchtopic commands as seen below:
That was me following the original example. Is that a bug or intended behaviour? EDIT: I did suspect there was one topic, but people seemed adam`ant that this was not the case so I fought for it :P |
OK. Granted.. This is 3.9.22 and I'm about to upgrade it to the latest (only stayed on this version because this module was sitting in limbo until I figured out how to configure it). However, in case this is of any interest, this just happened:
With every OFF or ON. So if whatever this is has been fixed, great. If not, maybe this will be helpful. |
As you are running WITHOUT a relay it is not a sonoff and therefore anything could happen but apparently I seem to have provided some nice features anyhow. It's intended behavior:
Your latest entry is also expected as you are using the same topic for I rest my case... |
Thank you! P.S. In my eyes you've created the best general purpose home automation ESP8266 firmware full stop. So yes, you definitely have provided some nice features :) So again, thank you! |
@arendst |
I added the page https://github.com/arendst/Sonoff-Tasmota/wiki/Expanding-Sonoffs to try and explain how to wire additional things (like this) to a sonoff and https://github.com/arendst/Sonoff-Tasmota/wiki/Adding-new-Module-types to provide hints on how to define a new module type. |
@davidelang If there are more relays it will start using numbers like POWER1 and POWER2 etc. BUT it will also control these relays. |
On Thu, 9 Mar 2017, Theo Arends wrote:
@davidelang If there are more relays it will start using numbers like POWER1 and POWER2 etc. BUT it will also control these relays.
If there is only one relay, and you hook a second switch, will it do
POWER1/POWER2, or is it only when you have two or more relays that it will add a
number to the POWER?
|
ok, so on a 4ch, a switch3 would duplicate key3? (since switchtopic changes the topic for the key# output as well) |
Yep |
in 4.0.3 you moved a bunch of things from the template only to user configurable, but you still have switch1 vs button1, is there a difference between them? or should one of them go away in a future version? |
Yes there is a big difference between them and they both will stay.
|
so if you set buttontopic to abc and switchtopic to def you can get up to 8 different messages from the sonoff? now that it's possible to set buttons on gpios, would it make sense to remove switches entirely and just use buttons? |
What I've tried to explain is that Buttons are there by default build in the hardware. Button1 addresses relay1. People wanted to control the relay also with an external button/switch without physical cabling to the the original button. So I had to come up with code that links switch1 to relay1 too. That's why both have to stay. The fact that Button pop up in the drop down box is that 'other' people wanted to configure buttons on non-sonoff hardware. It's confusing I know but that's because this software almost becomes a swish army knife... |
swiss army knives are very useful :-) it's just that in the process of becoming more general, it sometimes makes sense to revisit the reasons that things are what they are and check that they still make sense in the face of other features that have been added in the meantime. the need to duplicate the built-in buttons with externally connected switches makes sense. I'm just wondering if it would make more sense to have a way to redefine button1 to a different gpio and simplify things by eliminating the switch/button distinction. I've also been thinking that with the firmware becoming more general, it may make sense to reorganize the gpio definitions so instead of key1-key4 followed by switch1-4 we had all of *1 followed by all of *2 etc. This would make it easier to add additional items beyond 4, which is a limit we are bumping against with the non-sonoff uses |
With regards to the COMMANDS being blurted on every power change because there are no relays.. I now have two divergent behaviours from identically configured devices. Both have just one PIR as switch1 on GPIO14. One blurts out the COMMANDS when its state changes and the other does not. Both also the same version of the firmware. Exhibit A:
Exhibit B:
Am I missing something? EDIT: Thought I had noticed something different but I was wrong so I'm putting it back after deleting it. |
one thing is that it looks like these are different types of modules (the first is reporting sensor data) so the problem is that when it gets turned on, you get the output of commands, correct? the most common thing that will generate the commands output is if you send it an invalid command. Can you turn on more debugging (and/or monitor your mqtt bus) to see if there are any other commands being sent to the device? |
The other one has the same sensor modules. The logs had been going long enough (and with enough additional COMMANDS) to push those telemetry details out. Here it is again (I've increased the time delay and switched to a repeatable trigger as I'm experimenting with the use case of this particular PIR).
As you can see, the same sensors. |
Ok, we need to see all the mqtt commands that go to these devices. I'd bet that
there is something else being sent to the one that is generating the commands
output (like a dimmer command or something like that)
set logging to more debugging (4) and look at the output
|
YES! I guess this is something that worked with older firmware. WAY back when I had set up a script to automatically toggle a light when motion was detected. It would respond with:
I can't remember why I did this anymore.. I know there was a reason. Interesting that the exact same symptom occurs when you have multiple switches not linked to relays. Because in that situation I don't have any corresponding logic running outside. I'll disable the response and maybe that will clear up why I wanted/needed it in the first place. |
I would guess that with multiple switches and no relays, it's trying to internally generate the cmnd to turn on the relay and finding there is no such relay. |
If so that sounds like with the intent of it being used for just that purpose this would be something that could be considered a bug. i.e.. when you have multiple switches, no relays and switchtopic is not 0, avoid this branch of the code. |
That sort of configuration isn't tested that well, arendst is only testing sonoff devices, mostly without external switches/relays. It's up to the rest of us to test those configs and track down the oddities. :-) |
Oh, I'm all about tracking down bugs.. I find bugs in ALL software.. Going back to getting free versions of MS Win98 for finding bugs in that. I don't think the onus is on fixing non Sonoff bugs is on Theo at all.. As for providing solutions.. I just don't have the resources. But I'd be happy to help in any way I can. So I'm your man for any sort of testing.. My next focus is on trying to debug PIR behaviour to figure out whether it's a Sonoff problem, a Wemos problem, a power problem, a quality problem.. or something else. It's seems so random. |
I'm using Tasmota 5.12 on a Nodemcu board, where i've attached few sensors that work via I2c, and two sensor that works as switches, one IR and one Radar. The Nodemcu has no relays. I tried to follow instructions i've read here, to have 2 different MQTT messages for those sensors, but it seems i can't manage to get it working. I've configured Tasmota to use Switch1 and Switch2 for those IR and Radar sensors. 01:32:16 MQT: homeassistant/garage_sensors/POWER = ON No changes in POWERn After that i tried Switchtopic1 IR and Switchtopic2 Radar 01:33:20 MQT: homeassistant/Radar/RESULT = {"POWER":"OFF"} Still no POWERn What i'm missing? |
I am also having no luck getting POWERn..! SwitchTopic(n) seems to have no difference to just simply SwitchTopic |
Thank to Drzzs on Discord, the problem got solved.
My node is now working perfectly. Oh.. yeah, not so perfectly because i get false positives from IR sensor, but that is another problem. |
3.9.21 20170224 * Add ajax to web root page and web console (arendst#79) * Add commands SwitchMode1..4 and enable user switches 2, 3 and 4 (arendst#84, arendst#88) * Fix MQTT upgrade when webserver is active
Update from Tasmota
I just got my first multi switch (Sonoff 4CHPro/Tasmota 6.6.0.21) and I am struggling to set the "PowerOnState" for each switch? What I am trying to do is having switch 1,2,3 as PowerOnState 1 and switch 4 as PowerOnState 0 to use: poweronstate 1 Sofar this dosent work: It gives: Any and all help would be highly appriciated Thanks :-) |
Wow - you wen't back to the dark ages to find an issue that was questionably related to your request.
Please address any further questions to the Tasmota Support Discord Chat. The chat is a better and more dynamic channel for helping you. Github issues are best used for Tasmota software feature requests and bug reporting. Troubleshooting and setup assistance is more effective using an interactive forum. Please check the Contributing Guideline and Policy and the Support Guide. Thanks. Support InformationSee Wiki for more information. |
Sorry I didn't see it was from 2017 - Anyway thanks for trying to help! |
Set poweronstate so they boot off. |
Yes of course! THANKS! |
I find that I have a need to create some additional inputs (that will then be used to control different devices), and I see that switchtopic can be set to change the main button to send some other mqtt message.
If I add additional switches to the available GPIOs, is there a way to set switchtopics for them?
The text was updated successfully, but these errors were encountered: