Closed sl-wallace closed 1 year ago
Hi @sde1000 , I've had a go at implementing Occupancy Sensor support. It seems to work well with the sensor that I have, although so far I just have the one to try it with.
Really the only thing that stuck out as a bit tricky was the way the events are encoded - there's multiple properties per event notification. This is the list of events, which isn't the clearest way of explaining it but I suppose shows that there could be both a "Movement" and a "Still Occupied" event.
I decided to do a kind of bitmap type, using a Named Tuple. It means that things like e.g. this test code can work:
assert isinstance(decode_cmd, OccupancyEvent)
assert decode_cmd.movement
assert decode_cmd.occupied
assert not decode_cmd.repeat
assert decode_cmd.sensor_type == "movement"
Let me know what you think, I'd be happy to try some other way of representing the events if you can think of something neater.
That sounds sensible, and the pull request looks good to me on a first readthrough.
I'm afraid it will be a few more days before I have time to have a thorough look. Work deadlines :-(
All good, thank you.
Implements support for commands, responses and events from IEC 62386 part 303: "Input devices — Occupancy sensor"