Open cristianchelu opened 5 months ago
It's not part of the TODO, I've seen that command as documented, but my device just doesn't make use of it ;)
You can see the defined events in the json (the link at the top) (as well as the SIID 1): https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:pet-feeder:0000A06C:mmgg-fi1:1
So event_occured 4 3 5 255
is feedstart
with outfood-id=255
.
event_occured 4 2 4 1 5 255
would be feedstats
with outfood-num=1
and outfood-id=255
.
And event_occured 4 1 4 1 5 255
finally feedsuccess
with the same arguments.
The better question is: what do we do with these events?
Oh, I missed both that there's a link to the JSON version of the spec in the page and that there's more information within it, including the manufacturer / device info. Thanks for that!
And yes, great question -- I have no concrete idea.
I have little experience with ESPHome and just a casual user of HA, but I would imagine a psuedo-yaml like
sensor: # or some other component?
- platform: "miot"
miio_siid: 4
miio_eiid: 1
id: feed_event
internal: true
on_event:
- homeassistant.event:
event: esphome.feeder_feedsuccess
data:
outfood-num: !lambda return id(feed_event).properties[0].value # or some such
outfood-id: !lambda return id(feed_event).properties[1].value # or some such
So that I can listen to this event in home assistant and define my automations there, inspired by a quick read of esphome events and home assistant events, but this requires automations from what I understand.
If this is too hand-wave-y and that's-not-how-this-works I totally get it, but can't provide any helpful insights, and will happily sit on the sidelines until someone has a real idea.
That looks good, thanks! I've not used remote events yet, but I'll take a closer look soon. Out of curiosity: Do you plan to use that on the HA side?
Out of curiosity: Do you plan to use that on the HA side?
commented on Feb 5
:facepalm: I missed this somehow!
I believe I can use this on HA itself also; for the Mi Home app, my friends used to signal they arrived pet-sitting by pressing the feed button and I'd get a notification on my phone. The same would be doable and useful in HA.
However, handling events themselves via ESPHome automations can also be useful for e.g. tracking "total portions dispensed today", a feature available in the original app but for which an MCU property doesn't exist.
I could add a global integer and increment that with each feed-finished
event via globals.set, and expose the global as a sensor.
I can't depend on #16 for the above, because that would double-count the portions, the 4:4 feed-portions
property is updated at least twice per feed -- in multiple status and one finished messages.
P.S.: I have a feeling this device uses every little last feature of the miot protocol! :smile:
For the Smart Pet Food Feeder (mmgg.feeder.fi1), there's a physical/manual feed button that when pressed generates a number of messages from the MCU in the form
event_occured 4 3 5 255
.This seems to conform to the message format that I read in https://blakadder.github.io/miot/#event_occured , even though the device spec page doesn't list any events.
For this device, I haven't found a cumulative "portions dispensed today/total" property so counting the portions as they're dispensed is useful for deriving state.
I'm not sure if this is already considered in the TODO comment,
But leaving this here just in case it's useful.
I would deduce the below event stream to be
Example short press.
Pressing and holding down the feed button:
Pressing for even longer:
I'll be available for testing this on the real device if/when this is implemented.