Closed thomasaldershof closed 2 years ago
Alright turns out you don't automatically connect to a device. I am now sending a empty getProps to establish a connection.
Is there a better way? On your example page it seems creating the Device object is all that's needed. Maybe a device.connect() would be nice.
Yeah, you are right. Connection is created automatically when you send a command.
So in 0.3.1 I added device.connect()
method which will allow you to listen on notificationMessageStream
without sending any command prior to that.
Hello,
I am trying to listen to state changes, to automatically update the app, but I get no events. This is the used code
streamListener() { log("listening"); device.notificationMessageStream.listen((event) { log("received event"); event.params?.forEach( (key, value) { switch (key) { case 'power': properties['power'] = value; } }, ); notifyListeners(); }); }
First log is showing up. Received event is not when changing device state from the same device or e.g. Google home.