openhab-core
openhab-core copied to clipboard
Dynamic Profiles
I'd like having dynamic profiles that can be defined just as rules at runtime via textual configuration and/or UI. This would mean that you could have something like this in your config folder:
profiles/mybuttonprofiles.profile
// This is would be a reimplemntation of the 'rawrockeronoff' profile in xtext
profile trigger 'rawrockeronoff'
type Trigger //defines that it's a trigger profile
action
// "callback", "event" and "CommonTriggerEvents" would be magic variables that are pre-defined by the core in this context
if (CommonTriggerEvents.DIR1_PRESSED.equals(event)) {
callback.sendCommand(ON);
} else if (CommonTriggerEvents.DIR2_PRESSED.equals(event)) {
callback.sendCommand(OFF);
}
profile trigger 'mycustomprofile'
type Trigger //defines that it's a trigger profile
parameters
Boolean mycustomparameter
action
//do custom stuff considerung content of profile parameter 'mycustomparameter'
I'll put a bounty of 200 EUR on this which expires at 31/12/21 - DOD for the bounty would be to have a reviewed PR for adding textual configuration of profiles via xtext including support for parametrized profiles :) I don't use BountySource anymore as I really don't like their fee policy, also the website often does not work correctly - until I found a better platform, you just have to trust me :/
It is possible to define a profile using Python or JavaScript or Groovy. Access to all the core parts of openHAB needed to define and register the profile are exposed to them. I've seen an example which I just simply cannot find at the moment. I think maybe it was in an Issue in one of the github repos. ~I just can't find it though. So the best I can offer is that it is possible to do now in the other languages.~
Silly me, it's part of my own library's repo.
https://github.com/rkoshak/openhab-rules-tools/tree/main/multi_press some discussion of it at https://github.com/rkoshak/openhab-rules-tools/pull/34
It is possible to define a profile using Python or JavaScript or Groovy.
Thanks, I didn't know that yet! I'll give that a try and may write some documentation about that possibility.
I also think the JSR223 way is better then introducing a new DSL for profiles. Besides this, I also remember ideas/discussions on having a "ScriptProfile", which simply takes scripts as configuration parameters (similar to the ScriptActions of the rule engine). This would then even open the possibility to easily create such flexible profiles directly in the UI and using its script editor.
I'd love to see a ScriptProfile! That would make it much more accessible to regular users.
FYI I now have script-defined profiles implemented in a pre-release of the openhab-jrubyscripting helper library. You can check out the docs with an example at https://ccutrer.github.io/openhab-jrubyscripting/OpenHAB/DSL.html#profile-class_method. If you have a preference for a particular other language (javascript?) I'm sure you could pester the maintainer of the helper library for that language to get a similar implementation.
Can this be closed now that https://github.com/openhab/openhab-core/pull/3292 got merged?