merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
392 stars 61 forks source link

Xiaomi Smart Pet Food Feeder #485

Closed jubepue closed 10 months ago

jubepue commented 1 year ago

Describe the bug doesn't work with autocreated switch

Expected behavior make the autocreated switch work

Your config.json { "name": "Feeder", "ip": "192.168.107.23", "token": "xxxxxx", "deviceId": "467822596", "model": "mmgg.feeder.fi1", "pollingInterval": 10, "deepDebugLog": true, "buzzerControl": false, "ledControl": false, "childLockControl": false, "modeControl": false, "actionButtons": [ { "action": "2.1", "name": "Comedero", "params": [ 12 ] } ] },

Additional context with a custom action switch it works correctly. the switch needs a numerical parameter for the amount of food to dispense

merdok commented 1 year ago

What is the error which comes out? The default value is a 7 as numeric parameter so it actually should work...

jubepue commented 1 year ago

Hi, No error un the log. On my above config, it work for local and dispense 12 foods, but if i add cloud config: "micloud": { "username": "jubepue@gmail.com", "password": "xxxx”, "country": "de", "forceMiCloud": true, "timeout": 10000 },

It only dispense 1 food, not 12.

if i change: forceMiCloud": false It dispense 12 foods but I don't see the status of the created methods. logical because it is necessary to connect to the cloud for this device.

The same occur if i try CLI command: miot cloud action '{"did":"4678xxx","siid":2,"aiid":1,"in":[12]}' It dispense 1 food not 12.

miot send 192.168.107.21 -t 7a695a6365474b63335xxxxx action '{"siid":2,"aiid":1,"in":[12]}' it dispense 12 foods

merdok commented 1 year ago

Uffff, that is quite strange. I have no idea why there should be any difference between cloud and local. It should actually result in the same amount...

jubepue commented 1 year ago

After some tests i see in the logs what when i send an action the program change the params… "actionButtons": [ { "action": "2.1", "name": "Comedero", "params": [ 12 ] } ] For: '{"did":"46782xxxx","siid":2,"aiid":1,"in":[{"piid":5,"value":12}]}' it send only one food but with '{"did":"467822596","siid":2,"aiid":1,"in":[12]}' it sends 12 foods

Is there any way that the program sends exactly the parameters that are put in the configuration? It is a mistake because in local mode '{"did":"46782xxxx","siid":2,"aiid":1,"in":[{"piid":5,"value":12}]}' works fine and sends 12 foods

merdok commented 1 year ago

Now i am a little bit confused. Which is now the correct command which dispenses the expected amount of food?

The actions button params are parsed, since an action sometimes has parameters. In the case of action 2.1 there is a parameter for the property with id (piid) 5, hence the first param is assigned to that property and if there are any other parameters they are ignored.

jubepue commented 1 year ago

Not work (1 dispense food) Cloud: '{"did":"467822596","siid":2,"aiid":1,"in":[{"piid":5"value":12}]}'

Works(12 dispense foods) Cloud: '{"did":"467822596","siid":2,"aiid":1,"in":[12]}' Local: '{"did":"467822596","siid":2,"aiid":1,"in":[{"piid":5,"value":12}]}' and '{"did":"467822596","siid":2,"aiid":1,"in":[12]}'

Both command works in local but only the second in Cloud. No errors in logs because the first command dispense 1 food without error but not 12.

merdok commented 1 year ago

That is quite interesting, but i cannot tell why it is like that. I can of course introduce a raw actionButton flag, which when set will use the raw params without processing them, if that helps.

The other thing is, i am not sure how cloud would behave with more then 1 param...

jubepue commented 1 year ago

That is simple and perfect for this and future same mistakes.

jubepue commented 1 year ago

or be able to select cloud/local depending on reading, writing, action… "forceMiCloud": true, (now) (In the future)… miot_cloud: true # Enable miot cloud for entity (read, write, action) miot_cloud_read: true # Enable miot cloud (only read) miot_cloud_action: true # Enable miot cloud (only action)

In this way, if the cloud is necessary for a device to know its status, in case of not having internet access we can still execute actions locally, which is not possible now since either everything is local or everything is forced to cloud

merdok commented 1 year ago

But I still don't get the problem, you say it is working locally so when I even bother with cloud as your device supports local control?

Mixing cloud and local connections does not make sense...

jubepue commented 1 year ago

It makes all the sense in the world, because although it can send actions locally, this device needs the cloud to see the status of its properties (reading in the cloud), for example, to see the remaining days for cleaning or changing filters is only possible in the cloud, locally the result is always 0.

“propertyMonitor": [ { "property": "2.6", "name": "Food Needed", "value": 1, "valueOperator": "greaterOrEqual" }, { "property": "8.1", "name": "Clean" }, { "property": "11.2", "name": "Dessiccant" } ]

That is why it would be interesting in the future to be able to indicate that the readings are made from the cloud even though the actions are done locally. For most or all of the devices that the cloud currently marks as necessary, they could be actionated locally in case of not having punctual access to the Internet, even if the reading function was lost.

But a RAW action patch the actual bug.

jubepue commented 1 year ago

Hi, Any news?

merdok commented 1 year ago

Sorry, i am quite busy recently and did not have time to have a look... But i have it on my mind!

fmpmsilva commented 11 months ago

Hi. My pet feeder doesn’t work at all with homebridge. When I press the pet feeder HomeKit button nothing happens. Any idea?

merdok commented 11 months ago

You have to provide what pet feeder you have...

fmpmsilva commented 11 months ago

It’s a Xiaomi Smart Pet Feeder

fmpmsilva commented 11 months ago

I don’t know how to check the model

fmpmsilva commented 11 months ago

Maybe this mmgg-feeder-fi1_miap9CC7

merdok commented 11 months ago

That one should work. You should check if the connection to the device was successful.

fmpmsilva commented 11 months ago

Got it to work. How to set the amount of portions. It only dispenses 1 portion

merdok commented 11 months ago

You would need to create a propertyControl button with a custom amount of food to be dispensed.

killi23 commented 11 months ago

portion

Hi,did you happen to get the feeder to dispense more food other than the action button allows as per Merdoks reply via property control?

merdok commented 11 months ago

You have to create an action button for the action pet-feeder:pet-food-out. The parameter for the action is an integer number in the range 1-30 as per miot spec which controls how many food is dispensed. So you should use that.

fmpmsilva commented 11 months ago

I've created the action button with 20 on the parameter but it only serves one portion.

killi23 commented 11 months ago

Like wise . Pet-feeder:pet-food-out serves one portion of food = five pellets,when used as an action button . pet-feeder:feeding-measure under properties has a range of 1-30 but forgive my ignorance how to implement that in property control, my skills are not that of some here . Thanks

jubepue commented 11 months ago

Hi,

The connection to the feeder must be local, deactivate the cloud for the feeder. We are waiting for an update to be able to perform a RAW action

          ``{
                "name": "Comedero",
                "ip": "192.168.107.23",
                "token": "xxxxxxxxxxx",
                "deviceId": "467822596",
                "model": "mmgg.feeder.fi1",
                "pollingInterval": 10,
                "deepDebugLog": false,
                "customAccessory": true,
                "buzzerControl": false,
                "ledControl": false,
                "childLockControl": false,
                "modeControl": false,
                "actionButtons": [
                    {
                        "action": "2.1",
                        "name": "Comedero",
                        "params": [
                            14
                        ]
                    }…``
jubepue commented 11 months ago

It makes all the sense in the world, because although it can send actions locally, this device needs the cloud to see the status of its properties (reading in the cloud), for example, to see the remaining days for cleaning or changing filters is only possible in the cloud, locally the result is always 0.

“propertyMonitor": [ { "property": "2.6", "name": "Food Needed", "value": 1, "valueOperator": "greaterOrEqual" }, { "property": "8.1", "name": "Clean" }, { "property": "11.2", "name": "Dessiccant" } ]

That is why it would be interesting in the future to be able to indicate that the readings are made from the cloud even though the actions are done locally. For most or all of the devices that the cloud currently marks as necessary, they could be actionated locally in case of not having punctual access to the Internet, even if the reading function was lost.

But a RAW action patch the actual bug.

Please do not forgot!

merdok commented 11 months ago

RAW params are already available since around 2 months. That has to be enabled per device in the device class. The pet feeder could be switched to use the raw params now. The ijai.vacuum.v3 already uses that.

fmpmsilva commented 11 months ago

Still not working form. Only one portion.

jubepue commented 11 months ago

Can you indicate how to activate it? I can not find it

RAW params are already available since around 2 months. That has to be enabled per device in the device class. The pet feeder could be switched to use the raw params now. The ijai.vacuum.v3 already uses that.

Can you indicate how to activate it? I can not find it

merdok commented 11 months ago

You should have a look at the device file located under modules, that is why I posted the device model which uses it as reference.

killi23 commented 11 months ago

Can you indicate how to activate it? I can not find it

RAW params are already available since around 2 months. That has to be enabled per device in the device class. The pet feeder could be switched to use the raw params now.

The ijai.vacuum.v3 already uses that.

Can you indicate how to activate it? I can not find it

May I ask if you were successful please ?

fmpmsilva commented 11 months ago

Hi,

The connection to the feeder must be local, deactivate the cloud for the feeder. We are waiting for an update to be able to perform a RAW action

          ``{
                "name": "Comedero",
                "ip": "192.168.107.23",
                "token": "xxxxxxxxxxx",
                "deviceId": "467822596",
                "model": "mmgg.feeder.fi1",
                "pollingInterval": 10,
                "deepDebugLog": false,
                "customAccessory": true,
                "buzzerControl": false,
                "ledControl": false,
                "childLockControl": false,
                "modeControl": false,
                "actionButtons": [
                    {
                        "action": "2.1",
                        "name": "Comedero",
                        "params": [
                            14
                        ]
                    }…``

Still nothing. Im using your config and only one portion

"name": "Pet Feeder", "ip": "xxxxxxxxxxxxx", "token": "xxxxxxxxxxxxxx", "deviceId": "xxxxxx", "pollingInterval": 10, "deepDebugLog": false, "buzzerControl": true, "ledControl": true, "childLockControl": true, "modeControl": true, "actionButtons": [ { "action": "2.1", "name": "Be", "params": [ "30"

merdok commented 11 months ago

As mentioned be @jubepue the connection to the feeder must be local and not over the cloud.

fmpmsilva commented 11 months ago

As mentioned be @jubepue the connection to the feeder must be local and not over the cloud.

IMG_0187

This was the problem

merdok commented 11 months ago

Yeah the correct type also needs to be provided as this is quite strict by the miot spec.

jubepue commented 11 months ago

Copy my configuration and change the IP, the token, the deviceId and your model

killi23 commented 11 months ago

I just want to say thank you to all. All up and running with a decent amount of dispensed food .Thank you . Fantastic plugin. On a side note can the plugin display a sensor for low water in the pet water fountain ?

merdok commented 11 months ago

@killi23 that should be possible with a propertyMonitor if the device reports the water level. You would need to check the miot spec for that https://www.merdok.org/miotspec/?model=mmgg.feeder.fi1

jubepue commented 11 months ago

A pet feeder with water control? I have a water fountain model mmgg.pet_waterer.wi11 I attach my configuration, modify it according to your model as @merdok has indicated.

"propertyMonitor": [ { "property": "7.1", "name": "Water", "value": false } ]

jubepue commented 11 months ago

You should have a look at the device file located under modules, that is why I posted the device model which uses it as reference.

I have created the device class, moved the js file but I have not been able to get the RAW to work, the result is the same, with cloud or without it, there is no difference when doing it this way. is there any manual? you can do it?

merdok commented 11 months ago

Probably doing something wrong. Putting that flag in the device class should disable param processing and sends them RAW.

jubepue commented 11 months ago

exactly where i put the flag and what to put?

merdok commented 11 months ago

Just have a look at the overrides section at the bottom here: https://github.com/merdok/homebridge-miot/blob/main/lib/modules/robotcleaner/devices/ijai.vacuum.v3.js

merdok commented 10 months ago

Food amount can now be configured! Sorry for the delay!

killi23 commented 2 months ago

Sorry to resurrect an old thread and thank you for adding food dispense amount . Do I still need to create an action button with dispense food amount option ( sorry obviously), as I have tried to update the plugin from 1.6.2 to latest and added dispense food amount only to get 5-6 portions ( I know the default portion is 7) The only time I get an adequate amount of portions is as discussed earlier edit the json config manually instead of in the plugin UI in 1.6.2 . Appreciate any advice .

merdok commented 2 months ago

Pet feeder devices have an extra configuration field which can be specified called foodAmount, that way the auto create food dispense button will take the specified value.

killi23 commented 2 months ago

Thank you for the fast reply . Will take that info and apply . Again thank you and sorry to bring up an old issue .