Hi,
First of all thanks for your great library. This is really useful for integrating remote sensors into Home Assistant.
In my case I have made one sketch that can be configured to use different sensors. So based on a config file for example temperature sensors or binary switches are defined which all use the same code. To make it readable I have spread the code over different files, where the temperature sensor HASensorNumber is in a different file as the devices HADevice and HAMqtt.
This gives issues as the order of initialisation of the global objects is not under my control, so I figured I need to create the sensors dynamically (like you suggested in this issue https://github.com/dawidchyrzynski/arduino-home-assistant/issues/103).
I haven't tested this but I guess it will work. The question I'm having now, is how to create multiple sensors dynamically? For examples if there are more binary switches.
Can you suggest how to do this?
thanks
Hi, First of all thanks for your great library. This is really useful for integrating remote sensors into Home Assistant. In my case I have made one sketch that can be configured to use different sensors. So based on a config file for example temperature sensors or binary switches are defined which all use the same code. To make it readable I have spread the code over different files, where the temperature sensor
HASensorNumber
is in a different file as the devicesHADevice
andHAMqtt
. This gives issues as the order of initialisation of the global objects is not under my control, so I figured I need to create the sensors dynamically (like you suggested in this issue https://github.com/dawidchyrzynski/arduino-home-assistant/issues/103). I haven't tested this but I guess it will work. The question I'm having now, is how to create multiple sensors dynamically? For examples if there are more binary switches. Can you suggest how to do this? thanks