Skip to content
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

Added action for on/off switches (new device option switch_action, default false) #5276

Merged
merged 8 commits into from
Jan 11, 2023

Conversation

Mr-Groch
Copy link
Contributor

@Mr-Groch Mr-Groch commented Jan 5, 2023

Those wall switches (not switch modules) can be installed without wiring all buttons to lamp and used in automations to control lights wirelessly. Or even if wired it can be used to control other related lights in automations. Action topic is preferred to be used as trigger, rather than state (state topic changes also when last_seen, linkquality or other property changes, so it must be filtered)

@Koenkk
Copy link
Owner

Koenkk commented Jan 6, 2023

Such feature is not specific to this device, it can apply to every wall switch, right?

@Mr-Groch
Copy link
Contributor Author

Mr-Groch commented Jan 6, 2023

Basically yes, but problem is with naming - single switches actions can be named on and off always, but multi button switches endpoints are sometimes named like left, center, right, sometimes l1, l2, others just 1, 2, etc. I ddon't know well z2m code, so don't know if I can get endpoint name in fromZigbee converter (I wasn't able to find such example)

@Koenkk
Copy link
Owner

Koenkk commented Jan 7, 2023

My point is that this is basically duplicate information. It's the switch state but then just in another form. Can't this be easily solved with an HA automation?

@Mr-Groch
Copy link
Contributor Author

Mr-Groch commented Jan 7, 2023

In HA yes - there are device events like switched on / off or I can use trigger based on entity state - HA have logic do detect state changes, but I don't have HA in mind. Any other software that want to run something based on switch event needs to remeber current state to detect event - there is no possibility to make stateless software now to handle switch events

@Koenkk
Copy link
Owner

Koenkk commented Jan 8, 2023

Since this functionality is not specific to these TuYa devices, it should also be added to all other switches. (mainly the on_off fromZigbee converter. Here you can find code to retrieve the endpoint name:

const endpointName = definition.hasOwnProperty('endpoint') ?

@Mr-Groch
Copy link
Contributor Author

Mr-Groch commented Jan 8, 2023

OK, should I add action by defaut for all extend.switch() or like in this PR as option ?

@Koenkk
Copy link
Owner

Koenkk commented Jan 9, 2023

Not by default, this should be an option as not everyone will be interested in this. e.g. switch_action

@Mr-Groch Mr-Groch changed the title Added action for TuYa light switches (TS0011, TS0012, TS0013, TS0014) Added action for on/off switches (new device option switch_action, default false) Jan 9, 2023
@Mr-Groch
Copy link
Contributor Author

Mr-Groch commented Jan 9, 2023

Changed PR topic, and commited publishing action topic for all on_off converters when new switch_action device option is set to true

@Koenkk Koenkk merged commit 9ac3896 into Koenkk:master Jan 11, 2023
@Koenkk
Copy link
Owner

Koenkk commented Jan 11, 2023

Thanks, I've renamed it to state_action since we can also use it for other device types than switches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants