Have you looked for this feature in other issues and in the docs?
Briefly
Is your feature request related to a problem? Please describe.
_A clear and concise description of what the problem is._
I believe it is a problem when a switch/button isn't associated to a relay it defaults to relay1
Instead of a switch being standalone and using rules or KNX to give it function,
It will always control relay1 and do the rules or KNX events.
This makes no sense to me.
Describe the solution you'd like
_A clear and concise description of what you want to happen._
Change this code in support_tasmota.ino
void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
if ((device < 1) || (device > devices_present)) {
device = 1;
}
TO:
if (device < 1){
AddLog_P2(LOG_LEVEL_INFO, PSTR("ERR: device < 1 !! device=%d"),device);
\ would have thought this was an error condition
return;
}
#ifdef DO_NOT_ALLOW_STANDALONE_SWITCHES
if(device > devices_present)) {
device = 1;
}
#endif
Describe alternatives you've considered
_A clear and concise description of any alternative solutions or features you've considered._
None
Additional context
_Add any other context or screenshots about the feature request here._
The above Tests are done in a number of other places in the code base.
I don't use MQTT , so I have not made the mods anywhere else.
The result is Very Satisfying and Super Simple !!.
Using KNX & the extra input on Sonoff Mini's , I have an All Off/On switch for the room .
(Please, remember to close the issue when the problem has been addressed)
My Workaround for this problem is not correct.
a better solution would be to test if a switch or button has a corresponding relay and
return from ExecuteCommandPower if it doesn't.
or perhaps just
if ((device < 1)||(device > devices_present)){
return;
}
Have you tried "SwitchTopic" other than 0 as described here: https://github.com/arendst/Tasmota/wiki/Buttons-and-switches
With SwitchTopic 0 you can also have a rule that serves the switch instead of toggling the relay. E.g.:
rule1 on switch1#state=2 do delay endon on switch2#state=2 do delay endon on switch3#state=2 do delay endon on switch4#state=2 do delay endon
After enabling that rule "rule1 1" and having the "delay" in that rule replaced by what you need no relay is toggled.
I am using switches just to trigger rules. No relay is toggled by 4 switches on a device having 1 relay.
Closing this issue as has been answered and as it is duplicated. Sorry.
As explained before in other issues and in the docs, if you don't want buttons/switches to control relays, you can modify Tasmota's behaviour using rules. In the rule's cookbook are plenty of examples. There is no need to modify the code because your required behaviour is already supported and explained in the docs.
If you need help on configuring Tasmota, please address this to the Tasmota support chat
_(Tasmota's default behaviour in the case of 1 relay and several buttons/switches is the stair-light case. If needed any other behaviour you need to configure Tasmota using rules)_
Please, read the Contributing Guideline and Policy. Thanks.
See Wiki for more information.
See FAQ for common questions/answers and links if none of your question is in the list
See Chat for more user experience.
See Community for forum.
See Code of Conduct
A Tad hasty on closing My Issue ..
As I Mentioned , I am NOT using MQTT.
in support__switch.ino :: void SwitchHandler(uint8_t mode)
we have this code
if (!SendKey(KEY_SWITCH, i +1, switchflag)) { // Execute command via MQTT
ExecuteCommandPower(i +1, switchflag, SRC_SWITCH); // Execute command internally (if i < devices_present)
}
The sendkey will likely return true if you are using MQTT , therefore ExecuteCommandPower won't be called.
you are writing rules to overcome a problem that shouldn't be there in the first place.
The Default behavior of a switch that is not associated to a relay should be nothing.
If you want it to do something , write a rule.
Doesn't that make more sense ?
Sorry, rules are independent from mqtt. You don't need MQTT for using rules. Rules are a feature of Tasmota to config any behaviour you want.
The default of Tasmota is that buttons and switches are linked to relays.
If you need another behavior and unlink them, you just need to tell Tasmota what you want using rules. There is no need to modify the firmware. You need just to config Tasmota. That is why the support chat is aimed for that type of help and github issues are for bug reporting.
Please, search in the docs on how to use rules, search in issues for other examples (this issue has been addressed several times before) and find us in the support chat for a more interactive help.
The Default behavior of a switch that is not associated to a relay should be nothing.
The default is the light stair case (design decision). If you need another behaviour, just config tasmota using rules
I get that.
I am trying to make a point that the logic with choosing a function is wrong.
it should have no function
it should have no function
That is an opinion. For example, Tasmota by default starts as it is a sonoff basic module (design decision). And for example ESPEasy starts as you said, no functions and no modules associated (design decision), But in both approaches, you are allowed to modify behaviours. Nothing wrong with those approaches. Just a different starting point.
so lets say that 1 out of 100 users use the 2way switch idea, the rest turn it off
does that imply something needs to change ?
as far as using a 3v3 input of an ESP to traverse though the walls with other mains wiring is not something I would do anyway.
Thanks for your point of view, but due to backwards compatibility with other users setup, this is not going to be modified so as to not brake any actual setup. Tasmota has been downloaded more than 5 million times, so if it is not really necesary, we don't want to make breaking changes. Again, if you don't need the default, you can configure Tasmota to behave differently using rules, scripts, setoptions, switchtopic, switchmodes, timers, etc etc. Please check that this discussion has been done before in old issues. Thanks.
If this has been thrashed out before & the issue is backward compatibility , then clearly I'm not alone.
a Simple ifdef build option could tidy the issue up for ever.
a Simple ifdef build option could tidy the issue up for ever.
hehehe, yes it is called RULES and don't need a recompile ;)
You had opened another issue that is the same as this one #7590. Have you tried the chat?
If not, do you want any help on configuring Tasmota? Please, let's chat in the support chat (https://discord.gg/Ks2Kzd4)
In your main issue you said:
It will always control relay1 and do the rules or KNX events.
Sorry, That is not correct. When you definde rules for all states of the switch/button, it will not control the relay.
If you do the following:
switchtopic 0
switchmode2 1
rule1 1
rule1 on switch2#state=0 do delay endon on switch2#state=1 do KnxTx_Cmnd1 1 endon
when the switch2 is in OFF position, your device will do nothing
when the switch2 is moved to the ON position, your device will execute command KnxTx_Cmnd1 1
No relay is going to be toggled. No MQTT needed.
Hope this helps on understanding how Tasmota works and that the behaviour you need is easily doable by configuring Tasmota's rules.
yes , got shut down with a chap saying I wouldn't understand stuff.
had to leave the chat in frustration.
been messing with stuff for over 40yrs .
guess i am just outdated in my thinking .
I see your edit regarding method.
although you say No MQTT needed , I'd be guessing that switchtopic 0 is actually MQTT ?
then the sendkey returns true and executecommandpower isn't called
the config switchtopic 0 is the default for switchtopic but I added that in the list of commands as I did for rule1 1 in order to _set all the required commands_ that will allow the rules to execute.
Switchtopic needs to be 0 in order to let rules to execute because if it is set to any topic, will override rules. It was just that. No MQTT needed for rules to execute.
Please, test the commands I have posted.
I'll do some tests & figure out what actually lets sendkey return true.
many thanks for the feedback
Sendkey function is not used in the rules routine. For rules code, see the rules driver instead _(xdrv_10_rules.ino)_.
But please try the commands I have posted. They work as you need.
I'm referring to the place where my problem actually lies.
In the SwitchHandler routine.
if (!SendKey(KEY_SWITCH, i +1, switchflag)) { // Execute command via MQTT
ExecuteCommandPower(i +1, switchflag, SRC_SWITCH); // Execute command internally (if i < devices_present)
}
But because ExecuteCommandPower is also called from a number of other places , I modified it soas it doesn't do the default.
rules routine overrides that.
Please, try the default Tasmota codebase with the commands I posted.
ok , I'll give it a go .. ( he said begrudgingly )
thanks
as expected , using rules etc gets it working the way I want .
The elefant is still in the corner of the room tho .
Perhaps in the future there might be an extension to the config page that has things like that switchable via a checkbox.
In the meantime , I'll go and sit with the elefant and keep my mouth shut .
Thanks for your patience
Perhaps in the future there might be an extension to the config page that has things like that switchable via a checkbox.
Today is your lucky day.
Check the docs for TasUI (new hot stuff)
Direct link https://github.com/IOTReboot/TasUI
If you are using Tasmota 8 then you must enable CORS under wifi settings adding
http://tasui.shantur.com as domain.
Then go to http://tasui.shantur.com and that UI is going to be downloaded to your browser and then you can control and config your Tasmotas from there. The old UI is going to be there too if you need.
Thanks for the Heads UP
Will definitely give it go !
I did say I would be quite .... Dang
I presume it would be writing rules while the elefant & I , grind our ever diminishing teeth .
I'm Back.
In the interest of correctness , I should mention that the Rules that I used to stop the switch from controlling relay1 Does Influence the return Value of SendKey .
{"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":444,"Rules":"on switch2#state=1 do delay endon on switch2#state=0 do delay endon"}
Added a little log entry
if (switchflag <= POWER_TOGGLE) {
if (!SendKey(KEY_SWITCH, i +1, switchflag)) { // Execute command via MQTT
ExecuteCommandPower(i +1, switchflag, SRC_SWITCH); // Execute command internally (if i < devices_present)
}else{
AddLog_P2(LOG_LEVEL_INFO, PSTR("BAZ: SendKey returned True"));
}
}
Log entry's aftter hitting switch2
10:56:54 RUL: SWITCH2#STATE=1 performs "delay"
10:56:54 RSL: RESULT = {"Delay":0}
10:56:54 KNX: Button 2 = 1 sent to 3.3.1
10:56:54 BAZ: SendKey returned True
10:56:55 RUL: SWITCH2#STATE=0 performs "delay"
10:56:55 RSL: RESULT = {"Delay":0}
10:56:55 KNX: Button 2 = 0 sent to 3.3.1
10:56:55 BAZ: SendKey returned True
Most helpful comment
I'm Back.
In the interest of correctness , I should mention that the Rules that I used to stop the switch from controlling relay1 Does Influence the return Value of SendKey .
{"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":444,"Rules":"on switch2#state=1 do delay endon on switch2#state=0 do delay endon"}
Added a little log entry
if (switchflag <= POWER_TOGGLE) { if (!SendKey(KEY_SWITCH, i +1, switchflag)) { // Execute command via MQTT ExecuteCommandPower(i +1, switchflag, SRC_SWITCH); // Execute command internally (if i < devices_present) }else{ AddLog_P2(LOG_LEVEL_INFO, PSTR("BAZ: SendKey returned True")); } }Log entry's aftter hitting switch2
10:56:54 RUL: SWITCH2#STATE=1 performs "delay"
10:56:54 RSL: RESULT = {"Delay":0}
10:56:54 KNX: Button 2 = 1 sent to 3.3.1
10:56:54 BAZ: SendKey returned True
10:56:55 RUL: SWITCH2#STATE=0 performs "delay"
10:56:55 RSL: RESULT = {"Delay":0}
10:56:55 KNX: Button 2 = 0 sent to 3.3.1
10:56:55 BAZ: SendKey returned True