Yeah… I think your templatesensor works the same way, yes? I basically just copied your code and changed the bits that needed to be changed to support a binary_sensor. I would prefer it update immediately, but only when needed, of course. So I’ll work on that next.
Like I said , I have not had the time til test it fully yet, just know that is one of the issues with it.
I think something like subscribing to all state changes could be doable, but require some testing.
I actually managed (new to HA) to install both repositories through HACS. The templatesensor one I can “open” from UI → Configuration → + and search for it. But sadly the templatebinarysensor I can not find through this way.
I checked supervisor → system → logg, but saw nothing strange. But after your post I learned that I could pull logs from “core” and there it was:
2021-11-11 12:50:00 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration templatebinarysensor which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-11-11 12:50:00 ERROR (SyncWorker_1) [homeassistant.loader] The custom integration ‘templatebinarysensor’ does not have a version key in the manifest file and was blocked from loading. See Custom integration changes | Home Assistant Developer Docs for more details
I did try before to put my version of HA in the manifest.json of templatebinarysensor:
Didn’t change anything though, so I guess I have misunderstood some (or a lot) things.
Think I got it now, my manifest.json for (templatebinarysensor) looks like this: