Homey and Arduino

I have gotten the Arduino MKR WiFi 1010 to work with HomeyArduino app.

I have a stable connection and I can change capabilities from Homey on the Arduino board. I can execute actions and check conditions. But I have one problem…

I can not synchronize the state of the Arduino board on power cycle or reset. I have a sync function that contains this

Homey.setCapabilityValue(“onoff”,s_state,true);
Homey.setCapabilityValue(“dim”,s_intensity);
Homey.setCapabilityValue(“light_hue”,s_hue);
Homey.setCapabilityValue(“light_saturation”,s_saturation);

This is called from the setup function in the Arduino sketch, after Homey is initialized as follows:

Homey.begin(“AnimLED-C414”);
Homey.setClass(“light”);

Homey.addCapability(“onoff”, setStateCallback);
Homey.addCapability(“dim”, IntensityCallback);
Homey.addCapability(“light_hue”, HueCallback);
Homey.addCapability(“light_saturation”, SaturationCallback);

Homey.addCondition(“state”, getStateCallback);

I can get “dim”, “light_hue” and “light_saturation” to work if I spend som 10 seconds calling Homey.loop() and then sync, how ever “onoff” does not work. It would be kind of nice if I can get it to work and without the 10 sec delay.

Any solutions are welcome!

Thanks in advance!

Perhaps this works:

Homey.setCapabilityValue("onoff",s_state,true);
Homey.setCapabilityValue("onoff",s_state);
Homey.setCapabilityValue("dim",s_intensity, true);
Homey.setCapabilityValue("dim",s_intensity);
Homey.setCapabilityValue("light_hue",s_hue, true);
Homey.setCapabilityValue("light_hue",s_hue);
Homey.setCapabilityValue("light_saturation",s_saturation, true);
Homey.setCapabilityValue("light_saturation",s_saturation);

Which, from the source, seems to be equivalent to:

Homey.emit("onoff", s_state);
Homey.setCapabilityValue("onoff", s_state);
Homey.emit("dim", s_intensity);
Homey.setCapabilityValue("dim", s_intensity);
Homey.emit("light_hue", s_hue);
Homey.setCapabilityValue("light_hue", s_hue);
Homey.emit("light_saturation", s_saturation);
Homey.setCapabilityValue("light_saturation", s_saturation);

Hi,
How did you get it to work? I have the same device but it refuses to connect to the HomeyDuino app. It cant be discovered and it does not work if I put in the IP adress manually.
I have a WIFI connection with the WiFiNiNA library and i’m currently printing the IP on a display. I also see it among the WIFI devices in the router, so it feels like it’s not a problem with the actual connection.

I’m then running Homey.begin(“xxx”); and also Homey.loop(); in the loop method. But I still can not connect it to homey.

Do you have any tips and tricks?

Hi!

Did you get it working?
My MKR1010 won’t connect either, so I hope you can point me in the right direction :upside_down_face:.