I tweaked a few things to make the flow better and added some options to support that. v1.1 is up on GitHub.
Basically, the issue with all of this is that I haven’t found any way to change presence without triggering an event. That’s not so bad in itself but that complicates other things like when you want to disable and enable and the device has moved. At any rate, after a fair amount of tinkering, I decided that the best way to do this is to give an option to force the mode and then it will stay in that mode.
For disable, it stops responding to event changes after it is disabled and for enable it generates events as normal (same as original design). The new options, available for both disable and enable, are:
- auto: this is the normal mode where the hub tries to reach the sensor and marks it as present or not present based on that. The behavior is that it will start looking as normal and will react as normal.
- present: Forces the sensor to appear as being present even though it may not be
- not present: Forces the sensor to appear as being not present even though it may not be
Combining these makes it simpler to get the desired behavior. For reference, I personally use “not present” on disable and “auto” on enable. Taking that as an example, the sensor would be away when it is disabled so as to not interfere with SHM events and modes when it is not being used. When it is enabled, it returns to the normal state as it starts to look but does not force it be present
The flow now seems more smooth as long as you can tolerate the forced mode change and what effects it has on SHM or other things that might key off of its presence.