denysdovhan / vacuum-card

Vacuum cleaner card for Home Assistant Lovelace UI
https://denysdovhan.com/smart-home
MIT License
868 stars 524 forks source link

Clarify shortcut usage in readme.md #745

Open elronzo opened 2 months ago

elronzo commented 2 months ago

One does not necessarily need a script. A direct service call is possible:


shortcuts:
  - name: kitchen
    service: mqtt.publish
    service_data:
      topic: valetudo/JustForDemonstration/MapSegmentationCapability/clean/set
      payload: '{"segment_ids": ["2"], "iterations": 1, "customOrder": true}'
svenove commented 2 months ago

I struggle a bit with getting this to work.

shortcuts:
  - name: Stue
    icon: mdi:sofa
    service: xiaomi_miio.vacuum_clean_segment
    service_data:
      target:
        device_id: 553a536e86e5b116d6d6f
      data:
        segments: 20

When clicking the icon, I get: Failed to call service xiaomi_miio/vacuum_clean_segment. extra keys not allowed @ data['target']

Any idea?

elronzo commented 1 month ago

'data:' before 'segements:' is superfluous.

svenove commented 1 month ago

'data:' before 'segements:' is superfluous.

Tried removing it, but it still throws the same error. I’ve tried all kinds of variants and believe I’m really close, but can’t seem to get it just right…

service_data:
  target:
    device_id: 553a536e86e5b116d6d6f
    segments: 20

And


service_data:
  target:
    device_id: 553a536e86e5b116d6d6f
  segments: 20
elronzo commented 1 month ago

Your config needs to either look exactly as provided here: https://github.com/denysdovhan/vacuum-card/ (= You need to create a script in HA that makes the MQTT call) or use my variant (= do mqtt.publish directly). But not a mix of both.

svenove commented 1 month ago

I’m not trying to do a mqtt.publish, but to call a different service (“service: xiaomi_miio.vacuum_clean_segment”).

Since the mqtt.push-service can be called directly, I expect all kinds of service calls can be called directly?

elronzo commented 1 month ago

Valetudo uses MQTT. So you'll definitely need the MQTT part somewhere.

svenove commented 1 month ago

Valetudo uses MQTT. So you'll definitely need the MQTT part somewhere.

I don’t use Valetudo, I use the Xiaomi Miio integration.

The same code works fine when used in an automation. It’s when copying it from an automation and to the shortcut-section of this cards it fails.