Closed CarsonF closed 2 years ago
Then you can remove the whole people counter from
__init__.py
Yeah I tried all of that yesterday with a number file—I couldn't access roode config. I think I was missing this line to make it work:
cv.GenerateID(CONF_ROODE_ID): cv.use_id(Roode),
I also wanted to move persisted number python code to a separate persisted_number.py
but I think esphome tried to load it because of MULTI_CONF
so I gave up and merged it back into the file.
In ESPHome sense it is a number
so just put it to the number.py
like above and we are good to go 👍
This replaces the
sensor
for people counts with anumber
. Numbers are controllable which makes it much easier to change the state in HA UI & automation without having to create lambda API services.This number is configured for people counting so min=0, step=1, max is configurable.
It is an instance of a new
PersistedNumber
object I created, that saves/restores the value using a native esphome API. This removes our explicitEEPROM
dependency.This flash write is debounced and can be user configured, defaults to once a minute. https://esphome.io/components/esphome.html#adjusting-flash-writes In testing it seems pending writes are still saved on graceful reboot. Note that ESP8266 have this disabled by default, so...
Since this count was the only value that was persisted/"restored", I removed the
restore_values
config option in favor ofrestore_value
on the number component.~I couldn't figure out how to reference the roode platform outside of its platform setup, so for now it's just there. I suspect I just missed something and it can be moved to an independent
number
entry with the roode platform.~