dvdgeisler / DirigeraClient

Dirigera Client API: Java written client API to interface IKEA's new smarthome hub DIRIGERA
MIT License
74 stars 9 forks source link

Docker Install & Implementation Details #29

Closed martynwendon closed 1 year ago

martynwendon commented 1 year ago

Hey there,

Great work on reverse engineering the new Dirigera hub!

No "issue" as such, but I am going to dockerise the dirigera-client-mqtt gateway so it's easy to run up an instance of it.

I notice you use maven to build / package, but that's probably a bit overkill to put all of that in the docker image too.

What would be the base requirements for the dirigera-client-mqtt gateway in terms of Java, etc? Are you able to post a release .jar (binary) at all?

Also, a final question, does the dirigera-client-mqtt gateway use polling, or is it instant reaction using web sockets or something else?

Thanks for your help :-)

dvdgeisler commented 1 year ago

Hi,

Glad to hear that someone will use it :)

Dockerizing is a great idea. I actually had similar plans, as I wanted to offer it as a Home Assistant add-on. If I understand correctly, add-ons are distributed there as a docker container: https://developers.home-assistant.io/docs/add-ons/tutorial/

I would suggest implementing a multistage build in docker. I just uploaded an example about this: https://github.com/dvdgeisler/DirigeraClient/blob/feature/mqtt-docker/Dockerfile If I did everything right, the final image must contain only the jar, not the built environment.

To answer your question: The minimum Java version is 17. I can also provide a jar if multistage docker is not an option.

It's polling (10Hz). I don't know whether the Dirigera offers any alternative to this, yet i can't imagine that the IKEA app also runs on this approach. However, I am quite unfamiliar with WebSockets. I have to read up on it first.

Best, David

martynwendon commented 1 year ago

Hey David,

Thanks for the fast reply!

I'll take a look at the Dockerfile .... it will save me some time!

Is polling reliable enough to catch button presses for things like remotes?

I don't have a spare Dirigera (yet) to play around with for development reasons, but I noted on the output of https://github.com/wjtje/DIRIGERA/blob/main/logs/boot.log that it seems to be running an MQTT broker of its own. I would imagine that the IKEA App might be subscribing to that for updates, at least I can't think of any other reason for them to run a local MQTT broker.

Martyn

dvdgeisler commented 1 year ago

I just went through my captured communication between dirigera and IKEA's smart home app, and found this: image Apparently WebSockets are used!

dvdgeisler commented 1 year ago

Is polling reliable enough to catch button presses for things like remotes?

No, button presses or binary changes in sensors (e.g. motion sensor) are not catched by this polling approach (not even sporadically). However, you made my day by pointing me in the WebSockets direction. I'm pretty sure thats the way to catch stuff like that. I'll come up with some new code soon :)

martynwendon commented 1 year ago

Good spot on the websockets :-)

As I mentioned it does seem to be running an MQTT broker there, which do support websockets too.

I can't see enough of your trace capture to spot the format though, is it just a JSON payload or does it look like an MQTT payload? Is there a specific TCP port it's using?

dvdgeisler commented 1 year ago

Its JSON: [truncated]{"id":"6dc7e86a-b26c-4e52-a545-2992c79c1abe","time":"2022-11-04T19:25:28.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:gatewayd","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec45

Maybe Mosquitto is running on this mysterical port 9000...

TheMrBooyah commented 1 year ago

Hi,

Glad to hear that someone will use it :)

Dockerizing is a great idea. I actually had similar plans, as I wanted to offer it as a Home Assistant add-on. If I understand correctly, add-ons are distributed there as a docker container: https://developers.home-assistant.io/docs/add-ons/tutorial/

I would suggest implementing a multistage build in docker. I just uploaded an example about this: https://github.com/dvdgeisler/DirigeraClient/blob/feature/mqtt-docker/Dockerfile If I did everything right, the final image must contain only the jar, not the built environment.

To answer your question: The minimum Java version is 17. I can also provide a jar if multistage docker is not an option.

It's polling (10Hz). I don't know whether the Dirigera offers any alternative to this, yet i can't imagine that the IKEA app also runs on this approach. However, I am quite unfamiliar with WebSockets. I have to read up on it first.

Best, David

Currently I forked the repo to add authentication to the MQTT implementation (I run a broker that requires authentication) and add files to be able to create a docker image ready for use in Home Assistant.

It's not quite there yet but slowly getting there

dvdgeisler commented 1 year ago

I wrote a rudimentary WebSocket client and logged the events pushed by Dirigera. Unfortunately, it looks like only events are sent, which are also detectable by polling. Events raised by remotes, buttons, or motion sensors are not forwarded.

{"id":"45e2c0b9-97df-4123-b41c-0561db094094","time":"2022-11-22T18:44:50.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"34091581-6443-4cec-a0e0-3948db075624_1","createdAt":"2022-11-15T18:51:10.000Z","isReachable":true,"lastSeen":"2022-11-22T18:44:50.000Z"}}
{"id":"69ef5cf1-ebaa-4d6b-b086-71413d00ac35","time":"2022-11-22T17:45:00.338Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-22T17:45:00.338Z"}}
{"id":"9b7ec687-d7c8-4c26-a53b-ed0aac274be3","time":"2022-11-22T18:45:55.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"bd6add98-5a32-4bf4-8998-59645d46be84_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:59:43.000Z","isReachable":true,"lastSeen":"2022-11-22T18:45:55.000Z","attributes":{"isOn":true}}}
{"id":"39349731-dca8-47f6-a62f-58f31a64b148","time":"2022-11-22T18:45:59.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"bd6add98-5a32-4bf4-8998-59645d46be84_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:59:43.000Z","isReachable":true,"lastSeen":"2022-11-22T18:45:59.000Z","attributes":{"isOn":false}}}
{"id":"6770d3f0-b2a9-4fb6-81c5-755c338de185","time":"2022-11-22T17:46:00.374Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-22T17:46:00.374Z"}}
{"id":"692329c8-b036-4930-ad64-d7500e2db480","time":"2022-11-22T18:46:31.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"0635423b-3331-4d47-9252-1a37c97a58d2_1","createdAt":"2022-11-15T19:13:33.000Z","isReachable":true,"lastSeen":"2022-11-22T18:46:31.000Z"}}
{"id":"61d60b8c-e314-4a8d-ba68-a0e3afac728a","time":"2022-11-22T18:46:55.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"0afa1021-f261-4da4-96d7-8bfa1d5d5b74_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:57:22.000Z","isReachable":true,"lastSeen":"2022-11-22T18:46:55.000Z","attributes":{"isOn":false}}}
{"id":"b66ab350-42e6-46b5-bc48-ec2f9108b52c","time":"2022-11-22T18:46:56.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"936a74cf-7511-4fcd-88bd-b7445e9becaa_1","type":"light","deviceType":"light","createdAt":"2022-11-02T22:02:59.000Z","isReachable":false,"lastSeen":"2022-11-22T06:29:15.000Z","attributes":{"isOn":false}}}
{"id":"378f9d25-cb0a-4fa7-ac09-897535d94b9e","time":"2022-11-22T18:46:59.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"0afa1021-f261-4da4-96d7-8bfa1d5d5b74_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:57:22.000Z","isReachable":true,"lastSeen":"2022-11-22T18:46:59.000Z","attributes":{"isOn":true}}}
{"id":"4fe8f8f5-8f74-44eb-b484-9bddcab5cb84","time":"2022-11-22T18:46:59.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"936a74cf-7511-4fcd-88bd-b7445e9becaa_1","type":"light","deviceType":"light","createdAt":"2022-11-02T22:02:59.000Z","isReachable":false,"lastSeen":"2022-11-22T06:29:15.000Z","attributes":{"isOn":true}}}
{"id":"f66d7a1a-31b0-44e6-b81f-4b113cf0f3d2","time":"2022-11-22T17:47:00.406Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-22T17:47:00.406Z"}}
{"id":"065a72ec-ef2b-45ae-ad5f-c7ed5e1a2d18","time":"2022-11-22T18:47:27.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"936a74cf-7511-4fcd-88bd-b7445e9becaa_1","type":"light","deviceType":"light","createdAt":"2022-11-02T22:02:59.000Z","isReachable":false,"lastSeen":"2022-11-22T06:29:15.000Z","attributes":{"colorMode":"color","colorHue":29.566120351731797,"colorSaturation":0.9993372179119}}}
{"id":"3342eb46-6bc5-4dd4-aaae-cf9bc692d3c3","time":"2022-11-22T18:47:27.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"0afa1021-f261-4da4-96d7-8bfa1d5d5b74_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:57:22.000Z","isReachable":true,"lastSeen":"2022-11-22T18:47:17.000Z","attributes":{"colorMode":"color","colorHue":29.566120351731797,"colorSaturation":0.9993372179119}}}
{"id":"74dde11b-cd80-49d4-953d-4595b166a030","time":"2022-11-22T18:47:34.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"936a74cf-7511-4fcd-88bd-b7445e9becaa_1","type":"light","deviceType":"light","createdAt":"2022-11-02T22:02:59.000Z","isReachable":false,"lastSeen":"2022-11-22T06:29:16.000Z","attributes":{"colorMode":"color","colorHue":29.999024463361252,"colorSaturation":0.6414288176740123}}}
{"id":"71aded20-40c2-44cd-8112-ec3fb2cbd32d","time":"2022-11-22T18:47:34.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"0afa1021-f261-4da4-96d7-8bfa1d5d5b74_1","type":"light","deviceType":"light","createdAt":"2022-11-16T19:57:22.000Z","isReachable":true,"lastSeen":"2022-11-22T18:47:18.000Z","attributes":{"colorMode":"color","colorHue":29.999024463361252,"colorSaturation":0.6414288176740123}}}
{"id":"ffe650f7-f520-418a-9ee4-a283db2454e8","time":"2022-11-22T17:48:00.439Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-22T17:48:00.439Z"}}
martynwendon commented 1 year ago

That's a shame :-(

Mind sharing how the WebSocket client works? I'd like to have a poke around with it in node-red.

dvdgeisler commented 1 year ago

Sure: https://github.com/dvdgeisler/DirigeraClient/blob/feature/websockets/dirigera-client-examples/src/main/java/de/dvdgeisler/iot/dirigera/client/examples/websockets/WebSockets.java

its in the feature/websockets as example

martynwendon commented 1 year ago

Haven't had a chance to play yet, but are there any events sent for Scenes? Or is it only for devices within the Scene?

I wonder what is on port 9000, it responds with an HTTP 200 so seems to be another HTTP endpoint.

dvdgeisler commented 1 year ago

Haven't had a chance to play yet, but are there any events sent for Scenes? Or is it only for devices within the Scene?

Yes:

{"id":"fd0200fb-bb52-4842-bd26-319bbbc15b0a","time":"2022-11-23T11:17:00.428Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-23T11:17:00.428Z"}}
{"id":"5e95b091-ea01-4523-bcdb-19c655fa3df1","time":"2022-11-23T11:17:48.136Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:48.123Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-22T15:00:00.091Z","lastTriggered":"2022-11-22T15:00:00.091Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"966c2dc6-7507-499d-8e09-8a0a98365351","time":"2022-11-23T11:17:48.194Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:48.123Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:48.158Z","lastTriggered":"2022-11-23T11:17:48.158Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"ed60c71c-799b-4057-958b-072620cb433e","time":"2022-11-23T12:17:48.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"outlet","deviceType":"outlet","createdAt":"2022-11-15T18:51:10.000Z","isReachable":true,"lastSeen":"2022-11-23T12:17:48.000Z","attributes":{"isOn":true}}}
{"id":"0bd66b1d-f66e-481c-a46a-34e4966686a3","time":"2022-11-23T11:17:50.716Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:50.713Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:48.158Z","lastTriggered":"2022-11-23T11:17:48.158Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"004ec166-0381-4709-bc3f-9f4ec90f507c","time":"2022-11-23T11:17:50.780Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:50.713Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:50.734Z","lastTriggered":"2022-11-23T11:17:50.734Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"e40c4190-6d62-455b-8a2a-e59f47da7515","time":"2022-11-23T11:17:52.802Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:52.798Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:50.734Z","lastTriggered":"2022-11-23T11:17:50.734Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"6dfe473a-0320-4b63-a03f-2b9be1211a74","time":"2022-11-23T11:17:52.840Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:52.798Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:52.821Z","lastTriggered":"2022-11-23T11:17:52.821Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"e7135edb-f0d7-4dd1-98aa-cdea4b9db686","time":"2022-11-23T11:17:53.776Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:53.773Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:52.821Z","lastTriggered":"2022-11-23T11:17:52.821Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"d68ab4c4-96e6-4471-9a7a-f3068764e9d3","time":"2022-11-23T11:17:53.838Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:53.773Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:53.796Z","lastTriggered":"2022-11-23T11:17:53.796Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"08d61b3c-a5a4-47e2-ba83-e4bee192091d","time":"2022-11-23T11:17:57.554Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:57.551Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:53.796Z","lastTriggered":"2022-11-23T11:17:53.796Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"5d745af6-9b35-4f65-ad6f-b60a90ed39b8","time":"2022-11-23T11:17:57.610Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:57.551Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:57.571Z","lastTriggered":"2022-11-23T11:17:57.571Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"556ae6e4-500a-4198-a4a3-627c34aab07d","time":"2022-11-23T11:17:58.279Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:58.276Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:57.571Z","lastTriggered":"2022-11-23T11:17:57.571Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"6c0a1f04-f252-4103-81a1-2ee1c25946a7","time":"2022-11-23T11:17:58.337Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:17:58.276Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:58.297Z","lastTriggered":"2022-11-23T11:17:58.297Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"a4ca032e-af80-4864-a3c7-312a4df8f2f9","time":"2022-11-23T11:18:00.454Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:timeservice","type":"deviceStateChanged","data":{"id":"72a7eec1-eb69-477b-afaf-4bf9b5ec457b_1","type":"gateway","deviceType":"gateway","lastSeen":"2022-11-23T11:18:00.454Z"}}
{"id":"1470db87-3530-48d7-b55f-4e251d67b849","time":"2022-11-23T11:18:03.161Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:18:03.157Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:17:58.297Z","lastTriggered":"2022-11-23T11:17:58.297Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"d570d0e5-5b61-4a49-806c-226a7d1d918c","time":"2022-11-23T11:18:03.192Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:18:03.157Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:18:03.179Z","lastTriggered":"2022-11-23T11:18:03.179Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"20a16bb9-5eb6-4c15-b588-785eed5b15f9","time":"2022-11-23T11:18:04.436Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:18:04.423Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:18:03.179Z","lastTriggered":"2022-11-23T11:18:03.179Z","undoAllowedDuration":30,"lastUndo":"2022-11-16T19:58:37.655Z"}}
{"id":"9829cd8e-4b91-450a-89c2-71bb73ede106","time":"2022-11-23T11:18:04.491Z","specversion":"3.23.0","source":"urn:com:ikea:homesmart:iotc:rulesengine","type":"sceneUpdated","data":{"id":"15bf9775-ea0f-4551-82d5-86baba045b21","info":{"name":"Growlight","icon":"scenes_briefcase"},"triggers":[{"id":"1f8d447c-e15b-4a1d-842e-7b1573202a13","type":"app","triggeredAt":"2022-11-23T11:18:04.423Z","disabled":false,"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}}},{"id":"02e61e22-c37b-411e-b30f-ba4fbd9c6ffa","type":"time","triggeredAt":"2022-11-22T15:00:00.069Z","disabled":false,"trigger":{"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],"time":"16:00"},"endTrigger":{"type":"duration","disabled":false,"trigger":{"duration":9000}},"nextTriggerAt":"2022-11-23T15:00:00.000Z"}],"actions":[{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"device","deviceId":"34091581-6443-4cec-a0e0-3948db075624_11","attributes":{"isOn":true}}],"createdAt":"2022-11-16T19:57:44.083Z","lastCompleted":"2022-11-23T11:18:03.179Z","lastTriggered":"2022-11-23T11:18:03.179Z","undoAllowedDuration":30,"lastUndo":"2022-11-23T11:18:04.456Z"}}
{"id":"a6659606-3aa8-4d0c-a23e-09b693f4e524","time":"2022-11-23T12:18:04.000Z","specversion":"3.91.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"34091581-6443-4cec-a0e0-3948db075624_11","type":"outlet","deviceType":"outlet","createdAt":"2022-11-15T18:51:10.000Z","isReachable":true,"lastSeen":"2022-11-23T12:18:04.000Z","attributes":{"isOn":false}}}

I turned a timed scene scene manually on, then clicked "Test my scene", and afterwards "Stop testing". The scene turns an outlet on/off.

I wonder what is on port 9000, it responds with an HTTP 200 so seems to be another HTTP endpoint.

Me too. Its not SSL encrypted (unlike the REST interface). Hence i have little hope of finding sth. relevant there. However, here an output of nmap:

PORT     STATE SERVICE  VERSION
8443/tcp open  ssl/http Node.js Express framework
9000/tcp open  http     Golang net/http server (Go-IPFS json-rpc or InfluxDB API)

Nikto didn't reveal anything interesting either:

❯ nikto -Display all -C all -host 192.168.188.67 -port 9000 -output report.html
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.188.67
+ Target Hostname:    192.168.188.67
+ Target Port:        9000
+ Start Time:         2022-11-23 13:05:11 (GMT1)
---------------------------------------------------------------------------
+ Server: No banner retrieved
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
+ Web Server returns a valid response with junk HTTP methods, this may cause false positives.
+ 26167 requests: 0 error(s) and 4 item(s) reported on remote host
+ End Time:           2022-11-23 13:08:03 (GMT1) (172 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
martynwendon commented 1 year ago

Perhaps port 9000 is for the future.

It's a shame the remotes, motion sensors, etc aren't surfaced over websocket. I mentioned Scenes as I could possibly set some dummy scenes (with an unused outlet for example) to motion sensor, remote actions, etc and then map the scene "event" back to the original device on the MQTT side e.g.

Motion Sensor 1 - Scene Name 1 (turns outlet on, not relevant) -> Scene Name 1 Event = Motion Sensor 1 Active Remote Button 2 - Scene Name 2 (turns outlet on, not relevant) -> Scene Name 2 Event = Remote 2 Button Pushed

Of course I can already achieve this with Homekit by mapping Dirigera devices back to node-red, but that's quite convoluted as it involves dummy devices in Homekit.

The above is still convoluted, but not quite so much .....

dvdgeisler commented 1 year ago

This is a great Idea. I just gave it a try. However, i failed by linking my light controller to the scene:

Checking the IKEA app, apparently, only shortcut buttons can trigger scenes. Unfortunately, i don't have one to test and to gain some insights about how they are getting linked.

Maybe someone can test this and post a dump here. My hope is we might see how the link between the scene and the shortcut button is stored in the Dirigera. Maybe we can transfer it to other remotes then.

martynwendon commented 1 year ago

Ah I see, is it not possible to trigger scenes from sensors? I don't have any sensors yet, but have some on order.

I guess they could be using Zigbee groups / scenes directly rather than "sensor -> hub -> scene actions" so it's just "sensor -> execute scene in group of devices". In which case the sensors would never appear as actionable events at the hub level :-(

TheMrBooyah commented 1 year ago

Just popping back in here to say I managed to successfully create an addon for home assistant. Add https://github.com/TheMrBooyah/hassio-repository as a repository. Fill out the requested details in the configuration and it should work like a charm.

Let me know if you encounter any problems.

daveabbott007 commented 1 year ago

Just popping back in here to say I managed to successfully create an addon for home assistant. Add https://github.com/TheMrBooyah/hassio-repository as a repository. Fill out the requested details in the configuration and it should work like a charm.

Just tested and it does work like a charm!! many thanks

dvdgeisler commented 1 year ago

Just popping back in here to say I managed to successfully create an addon for home assistant. Add https://github.com/TheMrBooyah/hassio-repository as a repository. Fill out the requested details in the configuration and it should work like a charm.

Let me know if you encounter any problems.

Great job TheMrBooyah!

dvdgeisler commented 1 year ago

Ah I see, is it not possible to trigger scenes from sensors? I don't have any sensors yet, but have some on order.

Some good news. I went to IKEA today and bought a Shortcut Button. In a nutshell: It's possible to trigger scenes by controllers, yet with some limitations. i.e., i cant fetch STYRBAR's arrow buttons. Also, my motion sensor doesn't seem to work. However, for some remotes, it's even possible to distinguish between different press patterns (i.e., double press or long press). I uploaded an example at feature/scene-triggers.