Appdaemon - Better vacuum cleaner controls
This commit is contained in:
parent
1c2a41cef3
commit
dadf0735d1
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,5 +11,6 @@ packages/**/*_secret.yaml
|
||||
!/appdaemon/apps
|
||||
*.json
|
||||
*.hidden.*
|
||||
!python_scripts
|
||||
|
||||
!/lovelace/
|
||||
|
34
appdaemon/apps/vacuum.py
Normal file
34
appdaemon/apps/vacuum.py
Normal file
@ -0,0 +1,34 @@
|
||||
from entities import Entities
|
||||
|
||||
class Vacuum(Entities):
|
||||
def initialize(self):
|
||||
super().initialize()
|
||||
self.entity_id = self.args['entity_id']
|
||||
|
||||
self.run_in(self._setup, 1)
|
||||
|
||||
def _setup(self, kwargs):
|
||||
for zone in self.args['zones']:
|
||||
e = dict(self.args['zones'][zone])
|
||||
name = f'switch.vacuum_{zone}'
|
||||
self.register_entity(zone, name, True, "off", e)
|
||||
|
||||
self.listen_event(self.zone, 'VACUUM_ZONE')
|
||||
self.listen_event(self.all, 'VACUUM_ALL')
|
||||
self.listen_event(self.service, 'VACUUM_SERVICE')
|
||||
self.listen_event(self.home, 'VACUUM_HOME')
|
||||
|
||||
def zone(self, ev, data, kwargs):
|
||||
areas = []
|
||||
for zone in self.args['zones']:
|
||||
if self.e[zone].state == "on":
|
||||
areas.append(self.e[zone].attr['area'])
|
||||
|
||||
self.call_service("vacuum/xiaomi_clean_zone", repeats = 1, zone = areas)
|
||||
|
||||
def all(self, ev, data, kwargs):
|
||||
self.call_service("vacuum/start")
|
||||
def service(self, ev, data, kwargs):
|
||||
self.call_service("vacuum/send_command", entity_id = self.entity_id, command = 'app_goto_target', params = self.args['empty_spot'])
|
||||
def home(self, ev, data, kwargs):
|
||||
self.call_service("vacuum/return_to_base", entity_id = self.entity_id)
|
29
appdaemon/apps/vacuum.yaml
Normal file
29
appdaemon/apps/vacuum.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
vacuum:
|
||||
module: vacuum
|
||||
class: Vacuum
|
||||
global_dependencies:
|
||||
- base
|
||||
- entities
|
||||
|
||||
entity_id: vacuum.xiaomi_vacuum_cleaner
|
||||
|
||||
empty_spot: [26000, 26000]
|
||||
|
||||
zones:
|
||||
kitchen:
|
||||
# Left, bottom, right, top
|
||||
area: [23200, 21000, 27500, 25100]
|
||||
friendly_name: Köket
|
||||
hall:
|
||||
area: [23200, 25300, 27500, 28000]
|
||||
friendly_name: Hallen
|
||||
livingroom:
|
||||
area: [19000, 24000, 23000, 31200]
|
||||
friendly_name: Vardagsrum
|
||||
bedroom:
|
||||
area: [19000, 31500, 23500, 35500]
|
||||
friendly_name: Sovrum
|
||||
office:
|
||||
area: [23300, 31000, 27500, 35500]
|
||||
friendly_name: Kontoret
|
||||
|
@ -28,3 +28,5 @@ http:
|
||||
trusted_proxies: !secret proxy_hosts
|
||||
|
||||
cloud:
|
||||
|
||||
python_script:
|
||||
|
45
lovelace/vacuum_card.yaml
Normal file
45
lovelace/vacuum_card.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
type: vertical-stack
|
||||
cards:
|
||||
- type: custom:auto-entities
|
||||
card: { type: entities }
|
||||
filter:
|
||||
include:
|
||||
- entity_id: switch.vacuum_*
|
||||
- type: horizontal-stack
|
||||
cards:
|
||||
- type: entity-button
|
||||
entity: sun.sun
|
||||
icon: mdi:broom
|
||||
name: Städa
|
||||
tap_action:
|
||||
action: call-service
|
||||
service: python_script.event
|
||||
service_data:
|
||||
event: VACUUM_ZONE
|
||||
- type: entity-button
|
||||
entity: sun.sun
|
||||
icon: mdi:broom
|
||||
name: Städa Allt
|
||||
tap_action:
|
||||
action: call-service
|
||||
service: python_script.event
|
||||
service_data:
|
||||
event: VACUUM_ALL
|
||||
- type: entity-button
|
||||
entity: sun.sun
|
||||
icon: mdi:wrench
|
||||
name: Töm
|
||||
tap_action:
|
||||
action: call-service
|
||||
service: python_script.event
|
||||
service_data:
|
||||
event: VACUUM_SERVICE
|
||||
- type: entity-button
|
||||
entity: sun.sun
|
||||
icon: mdi:sleep
|
||||
name: Vila
|
||||
tap_action:
|
||||
action: call-service
|
||||
service: python_script.event
|
||||
service_data:
|
||||
event: VACUUM_HOME
|
@ -5,14 +5,7 @@ panel: true
|
||||
popup_cards:
|
||||
vacuum.xiaomi_vacuum_cleaner:
|
||||
title: Dammsugare
|
||||
card:
|
||||
type: entities
|
||||
entities:
|
||||
- vacuum.xiaomi_vacuum_cleaner
|
||||
- script.vacuum_home
|
||||
- script.vacuum_empty
|
||||
- script.vacuum_daily
|
||||
- script.vacuum_all
|
||||
card: !include vacuum_card.yaml
|
||||
cards:
|
||||
- type: custom:layout-card
|
||||
layout: vertical
|
||||
|
4
python_scripts/event.py
Normal file
4
python_scripts/event.py
Normal file
@ -0,0 +1,4 @@
|
||||
ev = data.get('event', None)
|
||||
ev_data = data.get('data', {})
|
||||
if ev:
|
||||
hass.bus.fire(ev, ev_data)
|
Loading…
x
Reference in New Issue
Block a user