-
Notifications
You must be signed in to change notification settings - Fork 23
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
HABApp libraries the second #457
Comments
You can have the class definition there but not the class instantiation. The class instantiation has to happen in a rule file.
From skimming over your code it seems you mainly want to interact with each device through hsb, on/off, level and color-temp values. I still think the it's easiest when you create four HABApp internal items per device and a rule per device which listens to a command event (you can reuse the openHAB ItemCommandEvent) on the items and then publishes to mqtt accordingly. On device update from mqtt it updates all four items. Grouping then becomes a matter of grouping the items and sending the events accordingly which is easy. The rule is basically a driver and the items represent the (most used) device state.
For me it's fine without issues: |
Alright then, I'll give it another shot and value the time you took with devotion. At the same time, these were just demonstrating excerpts, since as I mentioned before, I hitch-hike Milight to control e.g. my awning relays. They have such nice out-of-the-box useful (handheld as well as wall-mounted) remotes (EDIT: Milight that is) to signal my hubs for MQTT-messages to OH. So please don't think that lighting is the only application. That's exactly why I want libraries to feed my implementations (and I don't use OH items as relays to bridge whatsoever, since that is just to slow, but only to keep track of the states - EDIT3: or at least that was a train of thought in between years ago, I dunno any more, but this code-base works sufficiently). I know, that this is sort of rogue and not as intended. But well, in my sector you have to get creative to keep costs below par. Cheers for the prompt reply and will keep you in the loop, mate! EDIT2: And for me it doesn't: ADDITION: I didn't start refactoring yet, but say that I try drawing rules as sources from lib next now: Is it possible to instantiate an imported rule-class in multiple rule-files? E.g. having a lib/milight.py and importing plus instantiating it in rules/lighting.py as well as rules/awning.py? EDIT: It should be, because I instantiated sort of the class MilightDeviceRule(Rule) 50 times in one file via loops beforehand, resulting in MilightDeviceRule.1 to sort of .50. Conformation still appreciated. Cheers! |
Hey mate,
alright, I did my research on the approaches to clean libraries you mentioned here Yet, they don't provide any solution to my code. Reiterating...
Requirements
Description of the issue(s)
Example code
to be put in a library file
to be put in an implementation/configuration file
What do you suggest?
The text was updated successfully, but these errors were encountered: