Hypfer / lovelace-valetudo-map-card

Display the map from a valetudo-enabled robot in a home assistant dashboard card.
MIT License
243 stars 36 forks source link

How to create a custom button #99

Closed jonathanleinola closed 2 years ago

jonathanleinola commented 2 years ago

Hi,

I am trying to figure out how could i automate a task "clean a zone" and then stop. So that i could empty the trash bin and sent the robot back to home.

Is that possible via custom button? If yes, how can i do that?

Kindly, Jonathan

TheLastProject commented 2 years ago

Please take a look at https://github.com/TheLastProject/lovelace-valetudo-map-card/issues/97#issuecomment-915431566

TheLastProject commented 2 years ago

Closing this now, feel free to open if you need more info than is in that issue and the README

jonathanleinola commented 2 years ago

Oh, nice. Thank you. How about just a simple example for BasicControlCapability start? custom_buttons:

Should it be something like this?

Kindly, Jonathan

TheLastProject commented 2 years ago

It is YAML, so definitely not that as your indentation is all messed up.

Otherwise, maybe, I don't know Valetudo's MQTT API from the top of my head, the official Valetudo chat surely will know.

jonathanleinola commented 2 years ago

Nice, thank you! I figured it out :) It seems i can't send two commands with the same button? or do some logic behind that?

TheLastProject commented 2 years ago

You can call a Home Assistant script from a button and put your logic in a Home Assistant script

jonathanleinola commented 2 years ago

Okay, great :D I need to do some research on that then.

fpschrisiom commented 2 years ago

Just to add to this for others, here's my example for multiple buttons

custom_buttons:
  - service: script.clean_dining_room
    icon: mdi:table-chair
  - service: script.clean_living_room
    icon: mdi:sofa
  - service: script.clean_kitchen
    icon: mdi:stove
  - service: script.clean_landing
    icon: mdi:stairs
  - service: script.clean_toilet
    icon: mdi:toilet
  - service: script.clean_master_bedroom
    icon: mdi:bed-king
  - service: script.clean_master_bathroom
    icon: mdi:shower

and here's my background script


#Clean Dining Room
clean_dining_room:
  alias: "Dr Robotnick Clean Dining Room"
  sequence:
    - service: mqtt.publish
      data:
        topic: valetudo/robot/ZoneCleaningCapability/start/set
        payload: "[\"ID_OF_ROOM_HERE\"]"

In my configuration.yaml I have this line to point to my scripts.yaml

script: !include scripts.yaml