Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you execute actions? #114

Closed
fokcuk opened this issue Jun 25, 2021 · 19 comments
Closed

How do you execute actions? #114

fokcuk opened this issue Jun 25, 2021 · 19 comments

Comments

@fokcuk
Copy link

fokcuk commented Jun 25, 2021

I have successfully added Viomi vacuum cleaner and it worked great - pulled all the options in.
But how do you execute actions? I want to do defined room cleaning and under actions I have the following:

Actions

siid 4: aiid 7 Reset map: in: [] -> out: []
siid 4: aiid 10 Calibration: in: [] -> out: []
siid 4: aiid 11 Reset the usage time of the specified consumables: in: [35] -> out: []
siid 4: aiid 13 Choose room to clean: in: [36, 37, 38] -> out: []

The one in bold is the one I want to execute. 36, 37, 38 are defined by
siid 4: piid: 36 (clean-room-mode): (uint8, unit: none) (acc: ['write'])
{'value': 0,'description':'Global'}
{'value': 1,'description':'Along the edge'}
siid 4: piid: 37 (clean-room-oper): (uint8, unit: none) (acc: ['write'])
{'value': 0,'description':'stop'}
{'value': 1,'description':'Start'}
{'value': 2,'description':'Pause'}
siid 4: piid: 38 (clean-room-ids): (string, unit: none) (acc: ['write'])

Any assistance would be much appreciated

@al-one
Copy link
Owner

al-one commented Jun 25, 2021

Please provide the device model/urn and entity state attributes of the vacuum.

@fokcuk
Copy link
Author

fokcuk commented Jun 25, 2021

This is what I have:
urn:miot-spec-v2:device:vacuum:0000A006:viomi-v18:1

And these are the attributes that got pulled in:

Attributes
Model
viomi.vacuum.v18
Lan IP
192.168.1.124
MAC address
5c:6b:d7:17:04:fb
Firmware version
1.6.2_2251
Hardware version

Entity class
MiotVacuumEntity
Miot type
urn:miot-spec-v2:device:vacuum:0000A006:viomi-v18:1
Vacuum.status
4
Vacuum.fault
0
Vacuum.wdr mode
0
Vacuum.door state
3
Vacuum.contact state
0
Vacuum.mute
2
Vacuum.sweep type
0
Vacuum.mode
0
Voice.target voice
error
Voice.cur voice
girl_en
Voice.download status
0
Voice.download progress
100
Voice.voice url.error
-4003
Voice.voice mdfive.error
-4003
Map.map type
1
Map.map ID
1
Map.map name
error
Map.lang.error
-4003
Map.arrange room ids.error
-4003
Map.target room ID.error
-4003
Map.split points.error
-4003
Map.room name.error
-4003
Map.cur cleaning path
0123
Map.map list
[["2021/06/25/6153637412/378451326_084644151.bkmap","2021/06/25/6153637412/378451326_084643762.record",1624512315,"Map1",1]]
Map.oper result
0123
Map.auto area ID
0
Point zone.target point
0,0
Point zone.zone points.error
-4003
Point zone.restrict points.error
-4003
Order.order ID.error
-4003
Order.enable.error
-4003
Order.day.error
-4003
Order.hour.error
-4003
Order.minute.error
-4003
Order.repeat.error
-4003
Order.clean way.error
-4003
Order.suction.error
-4003
Order.water.error
-4003
Order.twice clean.error
-4003
Order.mapid.error
-4003
Order.room count.error
-4003
Order.room data.error
-4003
Order.dnd enable
0
Order.dnd start hour
22
Order.dnd start minute
0
Order.dnd end hour
6
Order.dnd end minute
0
Order.dnd timezone
0
Order.timestamp
0
Order.orderdata
Viomi vacuum.repeat state
0
Viomi vacuum.remember state
1
Viomi vacuum.mop route
1
Viomi vacuum.side brush life
98
Viomi vacuum.side brush hours
178
Viomi vacuum.main brush life
99
Viomi vacuum.main brush hours
358
Viomi vacuum.hypa life
98
Viomi vacuum.hypa hours
178
Viomi vacuum.mop life
100
Viomi vacuum.mop hours
180
Viomi vacuum.direction.error
-4003
Viomi vacuum.suction grade
0
Viomi vacuum.water grade
1
Viomi vacuum.map num
0
Viomi vacuum.time zone
-28800
Viomi vacuum.clean start time
0
Viomi vacuum.clean use time
20
Viomi vacuum.clean area
0
Viomi vacuum.clean map url
00000
Viomi vacuum.clean mode
0
Viomi vacuum.clean way
0
Viomi vacuum.cur lang
en
Viomi vacuum.cur map ID
1624512315
Viomi vacuum.cur map url
curMapUrl
Viomi vacuum.last update time
0
Viomi vacuum.consumable index.error
-4003
Viomi vacuum.clean room mode.error
-4003
Viomi vacuum.clean room oper.error
-4003
Viomi vacuum.clean room ids.error
-4003
Viomi vacuum.has map
1
Viomi vacuum.has newmap
0
Viomi vacuum.dust collection
0
Battery.battery level
100
State updater
lan
Sub entities
battery-3.battery_level-1

@al-one
Copy link
Owner

al-one commented Jun 25, 2021

service: xiaomi_miot.call_action
data:
  entity_id: vacuum.viomi_v18_entity_id
  siid: 4
  aiid: 13
  params:
    - 0 # Global
    - 1 # Start
    - xx,yy,zz # Room IDs

But no properties related to the room-ids were found.
Maybe you can get room-ids via MiHome mod by @vevsvevs

  1. Down apk from СКАЧАТЬ ВЕРСИЮ 6.x.x and install
  2. Start Mihome APP > Profile > Experimental features
  3. Check on Write custom log files and Enable app's debug mode
  4. Find the room-ids from vevs/logs/miio/xxxxxx.txt after restart app

There is a more recommended method:

Use this component to work with Xiaomi Cloud Map Extractor and Lovelace Xiaomi Vacuum Map card.

@fokcuk
Copy link
Author

fokcuk commented Jun 26, 2021

great! Will give it a go. So in HA I can use similar format to set_attributes and get_attributes as well?

@fokcuk
Copy link
Author

fokcuk commented Jun 26, 2021

I tried to use Xiaomi Cloud map extractor but it fails to do anything

@fokcuk
Copy link
Author

fokcuk commented Jun 26, 2021

I just used the modified app - really good info.
But I still cannot get it to work. This is what I see in the logs when I send vacuum to clean room:
{"params":{"did":"378451326","siid":4,"aiid":13,"in":[0,1,"3"]}} /miotspec/action
where "did" is my device ID.
Do I understand it correctly that it is a cloud only command? Is there a way to send it via the cloud?
I tried to follow the customization, but I dont understand the part where it says:

domain.your_entity_id:
  miot_cloud: true          # Enable miot cloud for entity (read, write, action)
  # miot_cloud_write: true  # (Optional) Enable miot cloud (only write)
  # miot_cloud_action: true # (Optional) Enable miot cloud (only action)
  # miot_local: true        # Force to read and write data in LAN

is it like that, where "domain" in my case is vacuum?:
vacuum.viaomi_s9_vacuum_robot_cleaner:
miot_cloud: true

Unfortunately it did not work:
Call miot action to Viaomi S9 Vacuum Robot Cleaner ({'did': '378451326', 'siid': 4, 'aiid': 13, 'in': [0, 1, '1']}) failed: {'code': -9999, 'message': 'user ack timeout'}

@al-one
Copy link
Owner

al-one commented Jun 26, 2021

great! Will give it a go. So in HA I can use similar format to set_attributes and get_attributes as well?

This component will get all readable properties, so you can get the desired properties from the entity state properties.

About set_attributes:

service: xiaomi_miot.set_property
data:
  entity_id: vacuum.your_vacuum_id
  field: vacuum.mode
  value: 3 # Strong

# Or

service: xiaomi_miot.set_miot_property
data:
  entity_id: vacuum.your_vacuum_id
  siid: 2
  piid: 19
  value: 0 # Silent

@al-one
Copy link
Owner

al-one commented Jun 26, 2021

Call miot action to Viaomi S9 Vacuum Robot Cleaner ({'did': '378451326', 'siid': 4, 'aiid': 13, 'in': [0, 1, '1']}) failed: {'code': -9999, 'message': 'user ack timeout'}

The error code -9999 in the logs, so your device may not support the execute actions in the local area network. Customize the entity attribute miot_cloud_action: true can only use the cloud when execute action.

# customize.yaml
vacuum.viaomi_s9_vacuum_robot_cleaner:
  miot_cloud_action: true

Recommended Customization Using The UI

If you integrate via token, you need to configure the account password in configuration.yaml before using the cloud mode:

# configuration.yaml
xiaomi_miot:
  username: xiaomi_username
  password: xiaomi_password
  # server_country: cn # location of xiaomi cloud: cn(default), de, i2, ru, sg, us

If you integrate via account, you do not need to configure the account password in yaml.

@fokcuk
Copy link
Author

fokcuk commented Jun 26, 2021

Finally got it to work! Thank you for your support!

@al-one al-one closed this as completed Jul 2, 2021
@blakadder
Copy link
Contributor

not related to the issue but does anyone have a clue what "wdr mode" is?

@al-one
Copy link
Owner

al-one commented Aug 23, 2021

not related to the issue but does anyone have a clue what "wdr mode" is?

Wide Dynamic Range Mode

@fhold
Copy link

fhold commented Oct 20, 2021

I can't get my dreame D9 Max to do room cleaning.
When i call this:

service: xiaomi_miot_raw.call_action
entity_id: vacuum.ayo
data:
  siid: 4
  aiid: 13
  params:
    - 0
    - 1
    - 2

i get the following error:
Aufrufen des Diensts xiaomi_miot_raw.call_action. extra keys not allowed @ data['params']. Got None

@al-one
Copy link
Owner

al-one commented Oct 20, 2021

@fhold The integration domain xiaomi_miot_raw does not belong to this component, and the integration domain of this component is xiaomi_miot.

service: xiaomi_miot.call_action
entity_id: vacuum.ayo
data:
  siid: 4
  aiid: 13
  params:
    - 0
    - 1
    - 2

@fhold
Copy link

fhold commented Oct 20, 2021

you are absoultly correct i installed the component via HACS and must have gotten the wrong one.

I also got now much more status information. The only thing is. If i try the command suggest from you it doesn't do anything. The room number might be wrong but i would expect to get an error then. Any ideas?

here is the config of the robot:

fan_speed_list:
  - Silent
  - Basic
  - Strong
  - Full Speed
battery_level: 100
battery_icon: mdi:battery-charging-100
fan_speed: Silent
model: dreame.vacuum.p2259
lan_ip: 192.168.20.82
mac_address: 24:18:C6:12:73:AF
firmware_version: 3.5.8_1004
hardware_version: ''
entity_class: MiotVacuumEntity
miot_type: urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2259:1
vacuum.status: 2
vacuum.fault: 0
vacuum.mode: 0
clean_logs.first_clean_time: 1632337219
clean_logs.total_clean_time: 722
clean_logs.total_clean_times: 17
clean_logs.total_clean_area: 655
time.time_zone: Europe/Vienna
time.timer_clean: ''
audio.volume: 31
audio.voice_packet_id: DE
audio.voice_change_state: '{"id":"DE","state":"success","progress":100}'
audio.set_voice.error: '-704030013 Property is not readable'
map.frame_info.error: '-704030013 Property is not readable'
map.map_extend_data.error: '-704030013 Property is not readable'
map.mult_map_state: 0
map.mult_map_info: >-
  {"object_name":"1745491455/447265963/9","md5":"44219b7f6b63ac600479d7b494251e61"}
do_not_disturb.enable: false
do_not_disturb.start_time: '22:00'
do_not_disturb.end_time: '08:00'
vacuum_extend.work_mode: 14
vacuum_extend.cleaning_time: 12
vacuum_extend.cleaning_area: 12
vacuum_extend.cleaning_mode: 0
vacuum_extend.mop_mode: 2
vacuum_extend.waterbox_status: 0
vacuum_extend.task_status: 0
vacuum_extend.clean_extend_data.error: '-704030013 Property is not readable'
break_point_restart-4-11: 1
vacuum_extend.carpet_press: 1
vacuum_extend.serial_number: P22591711EU00500ZM
vacuum_extend.remote_state.error: '-704030013 Property is not readable'
vacuum_extend.clean_rags_tip: 0
vacuum_extend.keep_sweeper_time: 0
vacuum_extend.faults: '0'
filter.filter_life_level: 91
filter.filter_left_time: 137
brush_left_time-10-1: 187
brush_life_level-10-2: 93
brush_cleaner.brush_left_time: 287
brush_cleaner.brush_life_level: 95
battery.battery_level: 100
battery.charging_state: 1
state_updater: cloud
sub_entities:
  - filter-11.filter_life_level-1
  - filter-11.filter_left_time-2
  - battery-3.battery_level-1
  - battery-3.charging_state-2
  - brush_cleaner-9.brush_left_time-1
  - brush_cleaner-9.brush_life_level-2
  - brush_cleaner-10.brush_left_time-1
  - brush_cleaner-10.brush_life_level-2
miot_action_error: '-704040005 Action does not exist'
miot_action_result:
  did: '447265963'
  miid: 0
  siid: 4
  aiid: 13
  code: -704040005
friendly_name: Ayo Robot Cleaner
supported_features: 12536

@al-one
Copy link
Owner

al-one commented Oct 21, 2021

@fhold The vacuum dreame.vacuum.p2259 does not have aiid 13 in siid 4. You can try:

service: xiaomi_miot.call_action
entity_id: vacuum.ayo
data:
  siid: 2
  aiid: 3 # start-room-sweep
  params:
    - aa,bb # room-ids

About room-ids, maybe you can get it in the log of Mihome mod (Create folder /sdcard/vevs/logs/ ⚠️).

@fhold
Copy link

fhold commented Oct 21, 2021

mh that does not work either :-( Interestingly I can start the vaccuum with aiid: 1.
Any further idea?
What does the 4 in the table below mean?
image

@al-one
Copy link
Owner

al-one commented Oct 22, 2021

@fhold aiid: 1 start sweep without room-ids.
4 - room-ids is the action param piid: 4.

@fhold
Copy link

fhold commented Oct 22, 2021

what i don't understand why it does nothing and i don't see any errors in the log. Any idea what i can try?

@al-one
Copy link
Owner

al-one commented Oct 23, 2021

@fhold

service: xiaomi_miot.call_action
entity_id: vacuum.ayo
data:
  siid: 2
  aiid: 3 # start-room-sweep
  params:
    - aa,bb # room-ids
  throw: true # throw action result to HA notifications.

Or you can find state attribute miot_action_result.
Get room-ids: #114 (comment)

For other questions, please open a new issue.

Repository owner locked as off-topic and limited conversation to collaborators Oct 23, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants