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

OpenHAB items can't be used a starters in routines #509

Open
alackmann opened this issue Aug 28, 2023 · 4 comments
Open

OpenHAB items can't be used a starters in routines #509

alackmann opened this issue Aug 28, 2023 · 4 comments

Comments

@alackmann
Copy link
Contributor

Having gotten OpenHAB and Google Assistant / Home integrated, I'm trying to have Switches or Lights triggered within OpenHAB become triggers for Google Home Routines.

It appears you should be able to do this. Google Home app (Android) now has the ability to create routines with Starters labelled "When a device does something" and shows Displays / Lights / Speakers / TVs (at least in my GH).

Unfortunately, even with bi-directional updating working for a Light or Switch OH Item within Google Home these Items never appear as options in Routines / Starters. If they could, this would significantly improve the functionality of the binding by providing a way to trigger events within the Google Home ecosystem from OpenHAB.

Also mentioned in https://community.openhab.org/t/issue-commands-to-ga/141423

@michikrug
Copy link
Collaborator

michikrug commented Aug 31, 2023

Hi, as already mentioned in the linked openHAB Community thread, I am convinced that the unavailability of the openHAB devices for starters is connected to the current limitation that we are not able to actively push the devices' states to the Google Home Graph, which is required to trigger such routines.

The way the current integration is working does only use a "pull" way of getting information. So only if you actively request a device's state, it is requested by the integration from your personal OH instance.

What would be required to do is a complete new solution that runs inside a user's OH instance and actively pushes state changes of items into the personal Google Home Graph of the user.
I do not see this happening in the scope of this project.

I did some experiments with dirty hacks that kinda work in that direction using rules and custom scripts, which actually made devices appear as starters as desired but also was not yet able to have devices appearing as starters for routines.


For some insights of what I did in my experiments...

Calling a custom Python script on state changes like:

rule "Report State Temperatur Bad"
when
        Item MiTempB_Temperature changed
then
        executeCommandLine(Duration.ofSeconds(4), "python3", "/etc/openhab/scripts/statereporter.py", "-i", "MiTempB")
end

The script then does a call to the local OH REST API to get the full item state and sends it to an endpoint of a modified version of this integration that has support for updating the Google Home graph.
Once a request is received, the regular logic is called to convert to item information into the Google Home required device data and pushed into the Home Graph.

The Python script can be accessed at: https://github.com/michikrug/openhab-google-assistant/blob/itemname-rework/stateReporter.py

The modifications made to talk to the Home Graph can be seen in (probably not including all changes):
https://github.com/michikrug/openhab-google-assistant/blob/itemname-rework/testServer.js#L11
and
https://github.com/michikrug/openhab-google-assistant/blob/itemname-rework/functions/index.js#L29-L42
and
https://github.com/michikrug/openhab-google-assistant/blob/itemname-rework/functions/openhab.js#L216-L263

@michikrug
Copy link
Collaborator

I actually set up a test routine just now and it indeed did work with my dirty hacks :D

@alackmann
Copy link
Contributor Author

What would be required to do is a complete new solution that runs inside a user's OH instance and actively pushes state changes of items into the personal Google Home Graph of the user. I do not see this happening in the scope of this project

That's great to hear you've been able to make it work. With that investigation - what's the feasibility of adding it into the Binding? I think this would add significant functionality to the integration.

@michikrug
Copy link
Collaborator

What would be required to do is a complete new solution that runs inside a user's OH instance and actively pushes state changes of items into the personal Google Home Graph of the user. I do not see this happening in the scope of this project

That's great to hear you've been able to make it work. With that investigation - what's the feasibility of adding it into the Binding? I think this would add significant functionality to the integration.

Into what binding? Currently, there is none taking care of such interaction.
We currently only rely on the exposure of OH through myOpenHAB to send and retrieve item information. No binding is involved.

I myself do not feel able to create one.

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

No branches or pull requests

2 participants