I'll assume that the larger world is rtl_433, mqtt, and Home Assistant
(HA). I think for systems that aren't that, the needed semantics are
close, but if you see it otherwise please describe.
rtl_433 has doctrine to just represent a transmission straightforwardly
in json. That has tremendous merit and I'm not trying to change that,
but it doesn't make sense to carry this approach all the way to the end
of the larger system.
Some things are "sensors" (HA term), which have new values over time.
The canonical example is temperature. Temperature fundamentally *is* a
sensor, and most devices transmit it periodically.
Some things are "binary sensors", which have values limited to on/off,
over time. Examples are doors and moisture sensors. Some devices might
send a value once a minute, and some might send a value when it changes.
Given lack of acks, and the desire for prompt notification, it seems
obvious that best practice (for a transmitter designer!) is to send the
value when it changes and also at some background rate. (We recently
have been talking about Govee which doesn't do it this way.)
Some things are "events", which is like "button pushed". This can be a
motion detection, and it can be a "user pushed button". The latter can
be used to "transition house to night mode", for example.
(Motion detection is conceptually messy. It can make sense to think of
it as a binary sensor, and it can make sense to think of it as an event.
An event firing corresponds to the off/on transition. There is no
"motion no longer detected".)
HA's notion of event is that it fires once and then can fire again. The
state is only the last time pushed. There is no notion of on and off.
https://www.home-assistant.io/integrations/event
There is support for events via mqtt:
https://www.home-assistant.io/integrations/event.mqtt/
I think it makes sense to sort things into two categories:
things intended to be binary sensors
things intended to be events
and to adjust the json keys in decoders to align appropriately, perhaps
using event_ as a prefix for events.
Then, in the mqtt scripts, we can produce mqtt event config for events.
A nuance is that if a device sends a button press, and sends 4
transmissions for redundancy, we really should be sending 1 event. This
means the json/mqtt bridge has to have state and keep track of the
last-fired time and suppress new events at least in the next 100ms or
whatever. (Really, devices should send a packet number or something to
allow merging the duplicate transmissions, but they are how they are.)
There was recently an query about the retained flag. It seems obvious
that sensors should have the retained flag set if they post only
occasionally, and not have it set if they post regularly. One would
like a sensor that is not reporting to show as unavailable. It also
seems obvious that events should never have the retained flag.
My own usage is using rtl_433_mqtt_relay.py with hand-configured
sensors, and I have not tried to set retain, nor have I noticed it.
That is working well, but I don't have any rtl_433 devices that only
report on state change.
I wonder if people think this makes sense, or if others see it
differently.