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

Add metadata support for genericmiot #1618

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rytilahti
Copy link
Owner

@rytilahti rytilahti commented Dec 5, 2022

This PR is continuation for #1581 and improves genericmiot by adding support for defining metadata (e.g., description, icon) for miotspec entities.

The idea behind this PR is to have consolidated descriptions, icons, etc. for standard properties, actions, and settings no matter what is defined in the the miotspec file.

At the moment the following metadata can be defined:

  • description (overrides the spec file given one)
  • icon
  • device_class

The structure for metadata files is:

<namespace>:
  services:
    <service_name>:
       action:
         <action_name>:
           # metadata
       property:
         <property_name>:
           # metadata

Example definition (namespace defined one level higher and thus not shown here):

description: Metadata miot-spec-v2 namespace
services:
  battery:
    description: Battery service
    icon: mdi:battery
    action:
      start-charge:
        description: Go charging
    property:
      charging-state:
        description: Charging status
      battery-level:
        description: Battery level
        icon: mdi:battery

The screenshot below shows what a simulated dreame.vacuum.p2009 looks like in homeassistant (compare to the one in #1581).

image

miiocli status output showing also items in Chinese that have no metadata defined:

Status (vacuum:status): Idle (value: 2) (from: Sweeping (1), Idle (2), Paused (3), Error (4), Go Charging (5), Charging (6), Mopping (7))
Error (vacuum:fault): 33  (min: 0, max: 100, step: 1)
[S] Fan speed (vacuum:mode): Full Speed (value: 3) (from: Silent (0), Basic (1), Strong (2), Full Speed (3))
Battery level (battery:battery-level): 8 % (min: 0, max: 100, step: 1)
Charging status (battery:charging-state): Charging (value: 1) (from: Charging (1), Not Charging (2), Go Charging (5))
Brush time left (brush-cleaner:brush-left-time): 4 days, 9:00:00 (min: 0, max: 200, step: 1)
Brush life level (brush-cleaner:brush-life-level): 85 % (min: 0, max: 100, step: 1)
Filter life level (filter:filter-life-level): 79 % (min: 0, max: 100, step: 1)
Filter time left (filter:filter-left-time): 2 days, 1:00:00 (min: 0, max: 150, step: 1)
Work mode (vacuum-extend:work-mode): 50  (min: 0, max: 50, step: 1)
Cleaned time (vacuum-extend:cleaning-time): 13:02:00 (min: 0, max: 32767, step: 1)
Cleaned area (vacuum-extend:cleaning-area): 18633  (min: 0, max: 32767, step: 1)
[S] Cleaning mode (vacuum-extend:cleaning-mode): 1 (value: 1) (from: 0 (0), 1 (1), 2 (2), 3 (3))
[S] Mop mode (vacuum-extend:mop-mode): 中 (value: 2) (from: 低 (1), 中 (2), 高 (3))
Water box attached (vacuum-extend:waterbox-status): 0 (value: 0) (from: 0 (0), 1 (1))
 (vacuum-extend:task-status): 0  (min: 0, max: 20, step: 1)
[S] break-point-restart (vacuum-extend:break-point-restart): 打开 (value: 1) (from: 关闭 (0), 打开 (1))
[S] carpet-press (vacuum-extend:carpet-press): 关闭 (value: 0) (from: 关闭 (0), 打开 (1))
Serial number (vacuum-extend:serial-number): piid 14 
[S] clean-rags-tip (vacuum-extend:clean-rags-tip): 0:48:00 (min: 0, max: 120, step: 1)
keep-sweeper-time (vacuum-extend:keep-sweeper-time): 446 days, 13:57:00 (min: -1, max: 1000000, step: 1)
Error status (vacuum-extend:faults): piid 18 
nation-matched (vacuum-extend:nation-matched): piid 19 None
relocation-status (vacuum-extend:relocation-status): 9806 None (min: 0, max: 1000000, step: 1)
[S] DnD enabled (do-not-disturb:enable): True
[S] DnD start (do-not-disturb:start-time): piid 2 
[S] DnD end (do-not-disturb:end-time): piid 3 
[S] mult-map-state (map:mult-map-state): Open (value: 1) (from: Close (0), Open (1))
mult-map-info (map:mult-map-info): piid 8 
[S] Volume (audio:volume): 90  (min: 0, max: 100, step: 1)
[S] Voice package id (audio:voice-packet-id): piid 2 
语音包切换时的状态 (audio:voice-change-state): piid 3 
Timezone (time:time-zone): piid 1 
[S] timer-clean (time:timer-clean): piid 2 
First cleaned (clean-logs:first-clean-time): 3324166495  (min: 0, max: 4294967295, step: 1)
Total cleaning time (clean-logs:total-clean-time): 1956346 days, 2:03:00 (min: 0, max: 4294967295, step: 1)
Total cleaning count (clean-logs:total-clean-times): 1271949570  (min: 0, max: 4294967295, step: 1)
Total cleaned area (clean-logs:total-clean-area): 3255108244  (min: 0, max: 4294967295, step: 1)

@rytilahti rytilahti force-pushed the feat/genericmiot_metadata branch from 3565661 to cb4dd19 Compare January 6, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant