FHEM Forum

FHEM => English Corner => Thema gestartet von: mgmino am 17 Dezember 2023, 15:34:37

Titel: 20_X10 add SetExtensions
Beitrag von: mgmino am 17 Dezember 2023, 15:34:37
The current 20_X10 module implements a few of the SetExtensions command set. Is there a plan to incorporate the SetExtensions.pm module?
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: Dr. Boris Neubert am 17 Dezember 2023, 17:38:19
Hi,

I am surprised to read that someone still uses the X10 system. I have decommissioned the equipment many years ago.

Please give it a try and incorporate the SetExtension! Since you can test it and can confirm it working, I would be happy to include the result in the official repository.

I now follow this thread.

Kind regards
Boris
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: mgmino am 17 Dezember 2023, 23:15:13
Thank you for the quick reply. I like the local (non cloud dependency) control of X10 and had a few modules laying around.

I will attempt to incorporate the SetExtensions module -- first I will add some documentation to confirm my understanding. If I get stuck, I will send you what I have.
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: mgmino am 20 Dezember 2023, 05:26:09
Boris - I have modified the 20_X10.pm module and attached it. Let me know if you see an issues. I have tested it with my hardware. A few questions:
20_X10.pm
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: Dr. Boris Neubert am 20 Dezember 2023, 09:59:38
Thank you for the enhancements.

I changed the reference from FS20 to X10 - this was a copy&paste error that has gone unnoticed for almost an eternity.

In scalar context return and return undef are the same. More on that topic here: https://stackoverflow.com/questions/3435122/whats-the-difference-between-return-and-return-undef-in-perl (https://stackoverflow.com/questions/3435122/whats-the-difference-between-return-and-return-undef-in-perl). Conclusion: one should use return undef.

I checked the new version into the subversion repository. You should be able to retrieve it by update tomorrow after 08:00 UTC+1.
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: mgmino am 20 Dezember 2023, 15:43:02
Thank you for the update.

Is the delete $modules{X10}{ldata}{$a[0]}; needed since it is overwritten in the next statement $modules{X10}{ldata}{$a[0]} = $hms_spec; ? I thought there was some backend relationship with FS20.

This has been a great experience on how to write a module. I will add the toggle feature for the next iteration and do some further code cleanup as my understanding improves.

One mystery is how does the function set (%functions_set) get communicated to fhem so it can populate the set drop down list?
Titel: Aw: 20_X10 add SetExtensions
Beitrag von: Beta-User am 21 Dezember 2023, 01:04:25
Zitat von: mgmino am 20 Dezember 2023, 15:43:02One mystery is how does the function set (%functions_set) get communicated to fhem so it can populate the set drop down list?
This is done by the "getAllSets()" function, see (unfortunately german) short explanation in https://wiki.fhem.de/wiki/DevelopmentModuleIntro#X_Set. That parses the returned text to extract the setters list.

There's also some further info found about SetExtensions in there, so you will find there you don't need to implement an own "toggle" function.