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

Dynamic Profiles #2201

Closed
pfink opened this issue Feb 15, 2021 · 7 comments
Closed

Dynamic Profiles #2201

pfink opened this issue Feb 15, 2021 · 7 comments
Labels
bounty enhancement An enhancement or new feature of the Core

Comments

@pfink
Copy link
Contributor

pfink commented Feb 15, 2021

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 :/

@rkoshak
Copy link

rkoshak commented Feb 16, 2021

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
rkoshak/openhab-rules-tools#34

@pfink
Copy link
Contributor Author

pfink commented Feb 17, 2021

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.

@kaikreuzer
Copy link
Member

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.

@rkoshak
Copy link

rkoshak commented Feb 22, 2021

I'd love to see a ScriptProfile! That would make it much more accessible to regular users.

@ccutrer
Copy link
Contributor

ccutrer commented Nov 8, 2022

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.

@J-N-K J-N-K removed the PR pending label Nov 29, 2022
@wborn
Copy link
Member

wborn commented Mar 20, 2023

Can this be closed now that #3292 got merged?

@rkoshak
Copy link

rkoshak commented Nov 14, 2024

I ran across this looking for something else.

Yes @wborn, this can and should be closed.

@J-N-K J-N-K closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants