Pet Feeder (mmgg.feeder.petfeeder)
Wh1terat opened this issue · 42 comments
Hi,
I have the Mijia branded pet feeder (XWPF01MG) - "urn:miot-spec-v2:device:pet-feeder:0000A06C:mmgg-petfeeder:1".
The XIAOWAN branded pet feeder is identical, even shares the same part number but uses "urn:miot-spec-v2:device:pet-feeder:0000A06C:mmgg-spec:1"
This spec is more thorough and matches the features available through the Mi home app.
Is there any way to use this miot spec ?
Have you tried to call this service?
service: xiaomi_miot.get_properties
data:
entity_id: sensor.mmgg_petfeeder_entity_id
mapping:
fault:
siid: 2
piid: 1
feedtotal:
siid: 4
piid: 2
foodstatus:
siid: 4
piid: 7
dryertime:
siid: 7
piid: 1
clearnserve:
siid: 8
piid: 1
throw: true
[
{"did": "fault", "siid": 2, "piid": 1, "code": -704030013},
{"did": "feedtotal", "siid": 4, "piid": 2, "code": -704040002},
{"did": "foodstatus", "siid": 4, "piid": 7, "code": -704040002},
{"did": "dryertime", "siid": 7, "piid": 1, "code": -704040002},
{"did": "clearnserve", "siid": 8, "piid": 1, "code": -704040002},
]
- 704040002: "service not found"
- 704030013: "property cannot read"
😭
So the spec of this model mmgg.feeder.spec
does not apply to your device mmgg.feeder.petfeeder
.
Indeed...which is odd because they carry the same part number of device.
So those features that are working in Mi Home will only be available with Miio ?
You can get the device states via custom attributes miio_properties
or sensor_commands
:
# customize.yaml
sensor.mmgg_petfeeder_entity_id:
miio_properties: prop1,prop2
sensor_commands:
get_prop:
params:
- prop1
- prop2
values: # to entity state attributes
- miio_prop1
- miio_prop2
And you can control the device via the service xiaomi_miot.send_command
:
service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_entity_id
method: set_prop1
params:
- value
Thank you, I will see what I can find 😄
I have also emailed the developer who was involved with creating the product @laughmaker - maybe some fix available.
Just done a packet capture and doesn't appear to be using miio locally, it's all between feeder <> xiaomi cloud on 54321.
I guess if no reply from manufacturer I will have to disassemble 😢
Maybe you can get miio logs via MiHome mod by @vevsvevs:
- Down apk from СКАЧАТЬ ВЕРСИЮ 6.x.x and install
- Start Mihome APP > Profile > Experimental features
- Check on
Write custom log files
andEnable app's debug mode
- Find the logs from
vevs/logs/miio/device-id.txt
after restart app and operate the device
I also have the same device and can’t access it
@blackdm666
I emailed developer and he suggested we speak on wechat but my account is inactive and cannot re-enable without help 😭
Asked about alternative methods to talk but no reply.
I took the device apart out of interest. It has ESP-WROOM-02D module however it looks like main MCU is "eastsoft hr8p506fhlq" which I know absolutely nothing about.
There's lots of test pads but nearly all for main MCU.
For ESP there is only 4 pin unpopulated header going to:
IO13
IO2
IO0
IO5
for hr8p506fhlq there is 5 pin populated header labeled:
RST
3V3
GND
SDA
SCL
Device also contains BM8563 RTC with battery which is nice touch for such an important device.
@al-one I appreciate this is only one device out hundreds in the ecosystem, but would you be able to chat to the developer?
It is easier than me making bad attempt with google translate!
何振东
联合创始人 技术合伙人
Co-Founder CTO
手机:130* * * * 7599
微信:130* * * * 7599
邮箱:****@mmgg.fun
地址:北京市海淀区京玺文化创业园B区2层
北京猫猫狗狗 Beijing Kitten&Puppy Technology Co., Ltd.
我已经联系了对方的微信,我会让他尽快回复你邮件,以帮助改进工作,再次感谢你,我现在使用手机不方便英语,抱歉!
@Wh1terat I discussed with him. Unfortunately, they can't support through OTA. However, there is another way to support this device. Please upgrade to the master branch and you will see some attributes in the entity. Then create a script to feed:
alias: mmgg_feed_now
mode: single
sequence:
- service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_entity_id
method: outfood
params:
- 1 # food amount 1-30
@al-one Ah I had hoped that perhaps there was a way of updating them via OTA.
Especially when you look how rich the MIoT spec is for their other "models" (same hardware).
Noticed another "new one" recently:
https://home.miot-spec.com/spec?type=urn%3Amiot-spec-v2%3Adevice%3Apet-feeder%3A0000A06C%3Ammgg-inland%3A1
Re the script, I updated to master branch and tried but no food was dispensed and no error raised.
@Wh1terat The new models don't help. They have different firmware. Please show me the entity attributes.
And try this service xiaomi_miot.send_command
:
service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_entity_id
method: outfood
params:
- 1
throw: true
@al-one They must have a way to update though as my unit has had 1 firmware update through MIHome since I bought it (something about fixing schedules) :/
Actually that's a good point, both sensor and switch entities are unavailable since update to master.
I've tried removing the device from the integration, restarting but it does not remove the device or it's entities.
Then tried re-adding it (with force update) and selection but no change.
How to force delete?
That removed it... but then when re-adding it does not add:
xiaomi_miot: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 651, in async_device_update
await task
File "/config/custom_components/xiaomi_miot/sensor.py", line 164, in async_update
await super().async_update()
File "/config/custom_components/xiaomi_miot/__init__.py", line 1225, in async_update
await self.hass.async_add_executor_job(partial(self.update_miio_command_sensors, cls))
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/xiaomi_miot/__init__.py", line 1245, in update_miio_command_sensors
if not self.miot_device or not isinstance(commands, dict):
File "/config/custom_components/xiaomi_miot/__init__.py", line 915, in miot_device
device = MiotDevice(ip=host, token=token, mapping=mapping)
File "/usr/local/lib/python3.9/site-packages/miio/miot_device.py", line 50, in __init__
raise DeviceException(
miio.exceptions.DeviceException: Neither the class nor the parameter defines the mapping
Setup of sensor platform xiaomi_miot is taking over 10 seconds.
What is your HA version ?
Operating System
Home Assistant OS 7.0.rc1
Supervisor
supervisor-2021.10.8
Core
core-2021.11.5
Looks like that exception was changed to be a warning quite a while ago in python-miio lib:
rytilahti/python-miio#1143
But HA has been using old package before that pull until only 2 days ago, but there's no release using it yet.
home-assistant/core#60650
🥳 🎈
Huge progress!
Just dispensed 2 units and it shows 2 units on MiHome!
Unfortunately it does not seem to have updated "feed_today" attribute, but maybe needs more time.
But importantly gained a whole load of new fields!
sensor.mmgg_petfeeder_bf89_pet_feeder
entity_class: MiotSensorEntity
home_room: Home Kitchen
miot_type: urn:miot-spec-v2:device:pet-feeder:0000A06C:mmgg-petfeeder:1
state_property: feeding_measure
state_updater: cloud
food_status: 0
feed_plan: 1
door_result: 0
feed_today: 0
clean_days: 9
outlet_status: 0
dryer_days: 15
weight_level: 4
wifi_led: 0
key_lock: 1
country_code: 255
feeding.measure.error: '-704030013 Property is not readable'
sub_entities:
- pet_feeder-2.feeding_measure-1
- feed_today
friendly_name: Pet feeder Pet Feeder Feeding Measure
supported_features: 0
switch.mmgg_petfeeder_bf89_feeding_measure
friendly_name: Pet feeder Pet Feeder Feeding Measure
icon: mdi:shaker
supported_features: 0
sensor.mmgg_petfeeder_bf89_feed_today:
entity_class: BaseSensorSubEntity
parent_entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
feed_today: 0
friendly_name: Pet feeder Pet Feeder Feeding Measure feed_today
supported_features: 0
Just tried toggling wifi_led on MiHome and this state updates instantly so maybe a few small tweaks needed, but I really must say this is a huge huge step forward!
👏
From my head, these are features which would would mean no need to ever use MiHome app again for this:
- Dispense Food with variable amount ✅
- Display food level (food_status) ✅
- Display fault status (?) ❌
- Manage feedplan (pushed to device so still works with no internet) ❌
- Display daily total of dispensed food (feed_today) ❌
- Display desicant life (dryer_days) and clean time (clean_days) ✅
- Display if unit is open (door_result) ✅
- Reset dryer_days & clean_days ❌
- Change country/region* ❌
*not even possible in app, only supports Chinese timezone so feedplan times must be calculated to match!
Display food level (food_status)
Display desicant life (dryer_days) and clean time (clean_days)
You can create sensor entities via template:
# configuration.yaml
template:
- trigger:
- platform: state
entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
attribute: food_status
sensor:
- name: mmgg_petfeeder_bf89_food_status
state: |
{% set sta = trigger.to_state.attributes.food_status | default | int(-1) -%}
{% set lst = ['full','less','empty'] -%}
{{ lst[sta] | default('unknown') }}
- trigger:
- platform: state
entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
attribute: clean_days
- platform: state
entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
attribute: dryer_days
sensor:
- name: mmgg_petfeeder_bf89_clean_days
state: |
{{ trigger.to_state.attributes.clean_days | default | int(0) }}
unit_of_measurement: days
- name: mmgg_petfeeder_bf89_dryer_days
state: |
{{ trigger.to_state.attributes.dryer_days | default | int(0) }}
unit_of_measurement: days
I'm not sure whether the value list of food status is these, you need to observe it yourself.
Reset dryer_days & clean_days
# scripts.yaml
mmgg_feeder_reset_clean:
sequence:
- service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
method: resetclean
params: []
mmgg_feeder_reset_dryer:
sequence:
- service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_bf89_pet_feeder
method: resetdryer
params: []
Thank you 😸 That's great, I'll publish my final stuff once I've tweaked it - few different enums for values.
Had a look at "getfeedplan1" and "getfeedplan2"
These return a list of feedplans as uint8[5] * 5.
index, hour, minute, portions, unknown(?)
getfeedplan1 = [
0, 255, 255, 255, 255,
1, 255, 255, 255, 255,
2, 255, 255, 255, 255,
3, 255, 255, 255, 255,
4, 16, 30, 8, 255
]
getfeedplan2 =[
5, 255, 255, 255, 255,
6, 255, 255, 255, 255,
7, 255, 255, 255, 255,
8, 255, 255, 255, 255,
9, 255, 255, 255, 255
]
(Mine ended up as index 4 as I had added/removed a few schedules when testing the unit.)
Not sure if there is a "setfeedplan1" ?
As for setting stuff, I'm struggling to work out how for key_lock and wifi_led.
Tried guessing names e.g set_wifi_led, setwifiled, etc but no luck.
Any ideas?
If you have an Android device, you can try #220 (comment), it can get all miio commands.
Finally a use for my free firetab!
A = key-stat - uint8 (0-1) *
method: keylock
params: [A]
A = led-control - uint8 (0-1)*
method: wifiledon
params: [A]
*(Guess they'd not heard of bool 🤣 )
AA = feedplan-id (0-9)
BB = feedplan-hour (0-24)
CC = feedplan-min (0-59)
DD = feedplan-unit (0-30)
method: feedListAdd
params:["AABBCCDD"]
method: feedListDel
params:["AABBCCDD"]
method: feedListEdit
params:["AABBCCDD"]
(edit and add do the same)
Turns out it does match up pretty well with mmgg.feeder.spec 😆
(I did try set-phone-time-zone & set-server-time-zone methods from ^ but seemingly not implemented as no change to schedule)
Total feed isn't seen so I guess this figure is just something stored in the plugin data and nothing to do with the device itself.
A new commit (a4a991c) allows you to extend the miot-spec. Can you help me adapt the device ?
This is an example:
hass-xiaomi-miot/custom_components/xiaomi_miot/core/device_customizes.py
Lines 370 to 398 in a4a991c
hass-xiaomi-miot/custom_components/xiaomi_miot/core/miio2miot_specs.py
Lines 503 to 511 in a4a991c
Hi , I feel the state of ( Display daily total of dispensed food (feed_today) ❌ ) is quite important to me.
I sniff the network flow it is using https://api.io.mi.com/app/user/get_user_device_data to get the feed_today
.
Here is the payload of request :
_nonce=/////7W%2BoXwBoXKO&data=7YknbSr1L8r%2BPL1Rd2KIPGjkTE8VfZEdWzlhwvnQ6V5a0iEuIm1GMM7/y9yWsJ1CGGYqB0sMgvQAS%2BC3IGMdw51r0ZflyOewekgzyuNUHtaS7o%2Bn/bPaZtz1dwfsyHw6/cLPsWVLWMnjgusipzTZk3EeR97git3PyWnq8fRU4DAaCNMMJTNASg89s9K8Kt9up5sYiBJtMYx56%2BBK3qAh6N6hnTSoIaFf2G8AHp8X51r6GA%3D%3D&rc4_hash__=W81NOnkVQ%2BuMH7K%2BN/KpNTWmbw/Rc6ZBdJkMpA%3D%3D&signature=VP0/LaLr2bA2GWjR52eo8ZOAzHQ%3D
response:
iSBaBE7XFejP9jCp8V0/SkDVvhyuY/Puyej6T6yh9+7Y/RKe8U92Bl/l3VVTUs+ppZ9hrd77/UT7KzyZHowDNwTwAESZcG/KunEGNZevAvWvU04mdeXbG1SBF+ODHaeh7tOmuTEADo3kctpbm+t07PS0HPuHmuZFP3qoH0DpY9er1JynsubjiyYf1UgmXe+HPhNrqj4=
How to decode it ?
Thanks
And it is using https://api.io.mi.com/app/home/rpc/248685518 to fetch the getprops
(#220 (comment))
{"id":2,"method":"getprops","accessKey":"IOS00026747c5acafc2","params":[]}
responds :
{ "code": 0, "exe_time": 154, "id": 2, "message": "ok", "net_cost": 298, "ot_cost": 1, "otlocalts": 1641470291309681, "result": [0, 0, 0, 0, 4, 0, 26, 1, 1, 1, 255] }
https://api.io.mi.com/app/home/rpc/248685518 to fetch the getfeedplan2
, payload
{"id":3,"method":"getfeedplan2","accessKey":"IOS00026747c5acafc2","params":[]}
responds
{ "code": 0, "exe_time": 114, "id": 3, "message": "ok", "net_cost": 296, "ot_cost": 0, "otlocalts": 1641470291718031, "result": [5, 255, 255, 255, 255, 6, 255, 255, 255, 255, 7, 255, 255, 255, 255, 8, 255, 255, 255, 255, 9, 255, 255, 255, 255] }
service: xiaomi_miot.get_device_data
data:
entity_id: sensor.mmgg_petfeeder_xxxx_pet_feeder
type: event
key: feedStats
I wrote support for the device including feed plans and submitted a pull to python-miio but lost interest after some differences of opinion with the developer.
This provides support for feedplans. Not sure how we'd go about implementing feedplans within this project though without some chunks of code.
Just installed and all entities are visable. I always use NODE-RED and I want to setup my own schedule. How can I send a signal to the feeder to feed x grams. So I want to have all control when to send and also based on other metrics in the future. I want to read the RFID chip (I have 2 cats) and based on this information feed the cat.
index, hour, minute, portions, unknown(?)
getfeedplan1 = [ 0, 255, 255, 255, 255, 1, 255, 255, 255, 255, 2, 255, 255, 255, 255, 3, 255, 255, 255, 255, 4, 16, 30, 8, 255 ] getfeedplan2 =[ 5, 255, 255, 255, 255, 6, 255, 255, 255, 255, 7, 255, 255, 255, 255, 8, 255, 255, 255, 255, 9, 255, 255, 255, 255 ]
This issue is closed, but it cloud help someone.
The last unknown(?) part is :
255 -> Feed plan not already executed and waiting for it...
0 -> Executed and done !
@Wh1terat Could you please explain again? How can I add Xiomi Pet Feeder? I'm a novice.
Also having some issues with this, I can dispense 1 food measure from the dashboard.
But nothing happens when I try to use the send_command like so:
alias: mmgg_feed_now
mode: single
sequence:
- service: xiaomi_miot.send_command
data:
entity_id: sensor.mmgg_petfeeder_entity_id
method: outfood
params:
- 10
Also having some issues with this, I can dispense 1 food measure from the dashboard.
But nothing happens when I try to use the send_command like so:
alias: mmgg_feed_now mode: single sequence: - service: xiaomi_miot.send_command data: entity_id: sensor.mmgg_petfeeder_entity_id method: outfood params: - 10
There is no oufood actions.
Hi,
I also have this device.
I would like to know if you were able to make it work with HA.
I can't get any information like your screenshots above.
I installed XIAOMI MIOT AUTO, connected with my cloud in the DE zone, but nothing comes up.
I found the smart food feeder but no information possible in HA.
How did you do ?
could you tell me what you put in your configuration.yaml and maybe customize.yaml?
Thank you for your help.
Which model do you have ?
i have this model :
https://home.miot-spec.com/s/mmgg.feeder.fi1
Xiaomi Smart Pet Food Feeder
thank you
Hi all !
I come back here because I answer myself.
I finally managed to integrate my device.
If it helps anyone else, here's what to do:
- On HACS download “XIAOMI MIOT AUTO”
- In settings and services install “XIAOMI MIOT AUTO”
- Download the “Get Mi Home devices token” software on a PC and with your Mi account retrieve the IP and token of your device.
Back on HA, open XIAOMI MIOT AUTO and select “Add device using host/token” (this is where I missed a few things) - And here I finally find my “mmgg.feeder.fi1” as in the screenshots above.
I still have to see how to automate a task and I would also like to create a remote control HA button to feed my cat.
If you have configuration information on this, do not hesitate to share your scenarios.
THANKS