diff --git a/config_creation/groups.yaml b/config_creation/groups.yaml index 5387dd7..d8f23c9 100644 --- a/config_creation/groups.yaml +++ b/config_creation/groups.yaml @@ -1,40 +1,60 @@ +# Add only entities here that are auto-discovered (not FHEM and KNX devices) + default_view: view: true icon: mdi:home living_area: name: Wohnbereich - view: true + entities: + - light.kuche_links + - light.kuche_rechts + - light.kuche_vorne + - light.wohnzimmer_kugel + - light.wohnzimmer_stehlampe + - light.wohnzimmer_stehlampe_oben + - light.wohnzimmer_regal_rechts + - light.wohnzimmer_regal_links bedroom: name: Schlafzimmer - view: true + entities: + - light.schlafzimmer + hallway: name: Gang - view: true + entities: + - light.gang_bogen + outside: name: Außen - view: true + office_martin: name: Arbeitszimmer - view: true + entities: + - light.arbeitszimmer_martin_oben + - light.arbeitszimmer_martin_unten + - light.arbeitszimmer_martin + office_rebecca: name: Arbeitszimmer Rebecca - view: true + entities: + - light.arbeitszimmer_rebecca + bathroom: name: Bad - view: true + other: name: Rest - view: true + first_floor: name: Oben - view: true + diff --git a/config_creation/main.py b/config_creation/main.py index c09ab53..86310fd 100644 --- a/config_creation/main.py +++ b/config_creation/main.py @@ -100,6 +100,17 @@ def add_fhem_devices(devices, groups): devices[device_type].append(device) +def add_light_groups(groups): + light_groups = { + f"light_{group_id}": { + 'name': content['name'] + " Lichter", + 'entities': [e for e in content['entities'] if e.startswith('light.')], + } + for group_id, content in groups.items() if 'name' in content + } + groups.update(light_groups) + + def main(): group_dict = yaml.load(open('groups.yaml')) @@ -110,6 +121,7 @@ def main(): with open('output/configuration.yaml', 'w') as output: output.write(open('manual_config.yaml', 'r').read()) yaml.dump(all_devices, output) + add_light_groups(group_dict) yaml.dump(group_dict, open('output/groups.yaml', 'w')) diff --git a/config_creation/manual_config.yaml b/config_creation/manual_config.yaml index 9f42063..e14e244 100644 --- a/config_creation/manual_config.yaml +++ b/config_creation/manual_config.yaml @@ -14,11 +14,30 @@ homeassistant: latitude: 49.369477 longitude: 10.9831468 - customize_glob: - cover.*: - half_position: 25 + customize: + cover.arbeitszimmer_martin_rollo: + half_position: 16 + cover.arbeitszimmer_rebecca_rollo: + half_position: 16 + cover.schlafzimmer_rollo_gross: + half_position: 16 + cover.schlafzimmer_rollo_klein: + half_position: 16 + cover.esszimmer_fenster_rollo: + half_position: 25 + cover.kuche_fenster_rollo: + half_position: 25 + cover.wohnzimmer_fenster_rollo: + half_position: 25 + cover.wohnzimmer_terrassentur_rollo: + half_position: 25 + + +# Custom stuff dimmer: +cover_half: + #logger: # default: info diff --git a/config_creation/scenes.yaml b/config_creation/scenes.yaml index f8cedaf..a50bc34 100644 --- a/config_creation/scenes.yaml +++ b/config_creation/scenes.yaml @@ -28,11 +28,11 @@ light.arbeitszimmer_martin_oben: state: on brightness: 186 - xy_color: [0.569, 0.397] + xy_color: [0.565,0.398] light.arbeitszimmer_martin_unten: state: on brightness: 247 - xy_color: [0.2, 0.102] + xy_color: [0.219,0.137] - name: Arbeitszimmer Martin Hell entities: diff --git a/config_creation/ui-lovelace.yaml b/config_creation/ui-lovelace.yaml index 66d278c..cece6e0 100644 --- a/config_creation/ui-lovelace.yaml +++ b/config_creation/ui-lovelace.yaml @@ -5,15 +5,29 @@ resources: url: /local/custom_ui/lovelace-toggle-lock-entity-row/toggle-lock-entity-row.js - type: module url: /local/custom_ui/mini-graph-card-bundle.js?v=0.4.3 + - type: module + url: /local/custom_ui/mini-media-player-bundle.js?v=1.2.0 + - type: js + url: /local/custom_ui/room-glance-card.js title: Home views: - cards: - - entities: - - light.wohnzimmer_deckenlampe - - light.wohnzimmer_kugel - image: /local/living_room.jpg - title: Wohnzimmer - type: picture-glance + - aspect_ratio: 16x9 + entities: + - group.living_area + image: /local/img/living_area_16_9.jpg + scenes: + - color: '#f07a1d' + name: Orange + scene: scene.wohnbereich_orange + - color: '#2eacd7' + name: Blau + scene: scene.wohnbereich_blau_grun + - color: '#9f9cac' + icon: 'mdi:weather-night' + name: Kuscheln + scene: scene.wohnbereich_kuscheln + type: 'custom:room-glance-card' - entities: - entity: light.kuche_deckenlampe name: Decke Küche @@ -71,11 +85,87 @@ views: show_header_toggle: true title: Gang type: entities + icon: 'mdi:sofa' title: Wohnbereich - - badges: - - sensor.fritz_box_7490_kbyte_sec_received - - sensor.fritz_box_7490_kbyte_sec_sent + - cards: + - aspect_ratio: 16x9 + entities: + - group.bedroom + image: /local/img/bedroom_16_9.jpg + scenes: + - color: '#ccc' + icon: 'mdi:sleep' + name: Dunkel + scene: scene.schlafzimmer_ganz_dunkel + - color: '#f07a1d' + name: Orange + scene: scene.schlafzimmer_orange + - color: '#fdef56' + name: Hell + scene: scene.schlafzimmer_ganz_hell + - color: '#2eacd7' + name: Blau + scene: scene.schlafzimmer_blau + type: 'custom:room-glance-card' + - card: + title: Lichter die noch an sind + type: entities + show_empty: false + entities: + - entity: group.light_hallway + icon: 'mdi:door-closed' + name: Gang + - entity: group.light_living_area + icon: 'mdi:sofa' + name: Wohnzimmer/Esszimmer + - entity: group.light_office_martin + icon: 'mdi:monitor-multiple' + name: Martins Büro + state_filter: + - 'on' + type: entity-filter + icon: 'mdi:bed-empty' + title: Schlafzimmer + - title: Martins Büro + icon: 'mdi:monitor-multiple' cards: + - aspect_ratio: 16x9 + entities: + - group.office_martin + image: /local/img/office_martin_16_9.jpg + name: Arbeitszimmer + scenes: + - color: '#f07a1d' + name: Orange + scene: scene.arbeitszimmer_martin_orange + - color: '#2eacd7' + name: Blau + scene: scene.arbeitszimmer_martin_blau_grun + - color: '#fff' + name: Hell + scene: scene.arbeitszimmer_martin_hell + type: 'custom:room-glance-card' + - entities: + - entity: light.arbeitszimmer_martin_deckenlampe + name: Deckenlampe + - entity: light.arbeitszimmer_martin + name: Fluter + - entity: light.arbeitszimmer_martin_oben + name: Stehlampe Oben + - entity: light.arbeitszimmer_martin_unten + name: Stehlampe Unten + - entity: cover.arbeitszimmer_martin_rollo + name: Rollo Arbeitszimmer + type: 'custom:state-card-custom-cover' + - entity: binary_sensor.arbeitszimmer_martin_bewegungsmelder_bewegung + name: Bewegung + secondary_info: last-changed + format: relative + - entity: sensor.arbeitszimmer_martin_bewegungsmelder_helligkeit + name: Helligkeit + show_header_toggle: false + type: entities + - cards: - entities: - entity: sensor.trockner_verbrauch name: Trockner aktuell @@ -145,15 +235,12 @@ views: type: 'custom:mini-graph-card' title: Admin - cards: - - entities: - - light.arbeitszimmer_martin_deckenlampe - - name: Rollo Arbeitszimmer - entity: cover.arbeitszimmer_martin_rollo - type: 'custom:state-card-custom-cover' - - binary_sensor.arbeitszimmer_martin_bewegungsmelder_bewegung - - sensor.arbeitszimmer_martin_bewegungsmelder_helligkeit - - switch.bad_lufter - show_header_toggle: false - title: Test - type: entities + - artwork: cover + entity: media_player.kitchenpi + hide: + power_state: false + source: true + volume: true + icon: 'mdi:spotify' + type: 'custom:mini-media-player' title: Test diff --git a/custom_components/cover_half/__init__.py b/custom_components/cover_half/__init__.py new file mode 100644 index 0000000..97bc362 --- /dev/null +++ b/custom_components/cover_half/__init__.py @@ -0,0 +1,45 @@ +""" Service to set covers half open""" +import logging +import voluptuous as vol + +from homeassistant.components.cover import DOMAIN as COVER_DOMAIN, ATTR_POSITION +from homeassistant.const import SERVICE_SET_COVER_POSITION, ATTR_ENTITY_ID + +# The domain of your component. Should be equal to the name of your component. +from homeassistant.helpers.service import async_extract_entity_ids + +DOMAIN = "cover_half" + +# List of component names (string) your component depends upon. +# We depend on group because group will be loaded after all the components that +# initialize devices have been setup. +DEPENDENCIES = ['group', 'cover'] + +# Name of the service that we expose. +SERVICE_SET_HALF = 'set_half' + +ATTR_HALF_POSITION = 'half_position' + +# Shortcut for the logger +_LOGGER = logging.getLogger(__name__) + +# Validate that all required config options are given. +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({}) +}, extra=vol.ALLOW_EXTRA) + + +async def async_setup(hass, config): + """Setup example component.""" + + async def async_set_half_service(service): + entity_ids = await async_extract_entity_ids(hass, service, expand_group=True) + for entity_id in entity_ids: + data = { + ATTR_ENTITY_ID: entity_id, + ATTR_POSITION: hass.states.get(entity_id).attributes.get(ATTR_HALF_POSITION, 20) + } + await hass.services.async_call(COVER_DOMAIN, SERVICE_SET_COVER_POSITION, data) + + hass.services.async_register(DOMAIN, SERVICE_SET_HALF, async_set_half_service) + return True diff --git a/custom_components/cover_half/services.yaml b/custom_components/cover_half/services.yaml new file mode 100644 index 0000000..9584e7a --- /dev/null +++ b/custom_components/cover_half/services.yaml @@ -0,0 +1,7 @@ + +dim: + description: Sets shutters half open + fields: + entity_id: + description: Name(s) of entities or groups + example: 'cover.living_room' diff --git a/custom_components/dimmer/__init__.py b/custom_components/dimmer/__init__.py index d4b057c..bd035cc 100644 --- a/custom_components/dimmer/__init__.py +++ b/custom_components/dimmer/__init__.py @@ -56,6 +56,9 @@ async def async_setup(hass, config): for entity_id in entity_ids: brightness = hass.states.get(entity_id).attributes.get('brightness', 0) + state = hass.states.get(entity_id).state + if state == 'off': + continue if factor is not None: data = {ATTR_BRIGHTNESS: clip_value(brightness * factor)} if offset is not None: diff --git a/todo b/todo index a034f22..7c5c881 100644 --- a/todo +++ b/todo @@ -1,38 +1,24 @@ - -- watson TTS add new RATE configuration and create merge request [ok] - - -- add brighter/darker action (service!) - -- add scenes [ok] - - try in frontend [ok] - - -- add half state for FHEM covers - - frontend cards for rooms with light stuff + - implement shutter - half open service [ok] + - frontend card: use group to set [ok] + - add HUE lights to groups + + - add KNX motion sensors & leds -- - -LIRC connection [ok] - Squeezebox: - standard setup - radio service FHEM: - - check FHEM reconnection [ok] - - what happens when FHEM stops? [ok] + - check FHEM reconnection - what happens when stick is pulled? Owntracks - try basic owntracks setup - -Other: - - grouped motion sensors (last motion where and when) - - media player card: - https://github.com/kalkih/mini-media-player - + +- grouped motion sensors (last motion where and when) +