commit 2d46ec2369edbe2b883e5d62ea9a9103cdf5e152 Author: dfcarvajal Date: Wed Apr 17 09:36:19 2019 +0000 Configuración Inicial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e679c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +* + +# Lista blanca +!*.yaml +!*.yaml_disable +!.gitignore +!*.md +!www +!www/** +!packages + +# Folders ignoradas. +.storage +.cloud +.google.token + +# Fijamos las que queremos ignorar por credenciales +ip_bans.yaml +secrets.yaml +known_devices.yaml diff --git a/automations.yaml b/automations.yaml new file mode 100644 index 0000000..f7325f7 --- /dev/null +++ b/automations.yaml @@ -0,0 +1,92 @@ +- id: '1548745063240' + alias: Persianas + trigger: +# - event: sunrise +# offset: 01:00:00 +# platform: sun + - event: sunset + offset: 00:15:00 + platform: sun + condition: [] + action: + - data: + entity_id: + - cover.persina_habitacion_principal + - cover.persina_habitacion_noha + - cover.persina_habitacion_mia + - cover.persina_habitacion_estudio + - cover.persina_salon_fase_dos + - cover.persina_salon_piscina + service: cover.close_cover + initial_state: 'on' +- id: '1550093153747' + alias: TEST - Notificaciones + trigger: + - entity_id: binary_sensor.movimiento_habitacion_estudio + from: 'off' + platform: state + to: 'on' + condition: [] + action: + - data: + message: saliendo de casa + service: notify.telegram_diego +- id: '1550094029238' + alias: Notificación a Isabel saliendo de casa al trabajo + initial_state: 'on' + trigger: + - entity_id: binary_sensor.puerta_entrada + from: 'off' + platform: state + to: 'on' + condition: + - after: 06:00 + condition: time + - before: 06:25 + condition: time + - condition: state + entity_id: binary_sensor.workday_sensor + state: 'on' + action: + - data: + message: Diego esta saliendo de casa + service: notify.telegram_isabel +- id: '1551289584925' + alias: Luz del Tendedero Encender + trigger: + - entity_id: binary_sensor.puerta_tendedero + from: 'off' + platform: state + to: 'on' + condition: + condition: or + conditions: + - condition: sun + after: sunset + - condition: sun + before: sunrise + action: + - service: homeassistant.turn_on + data: + entity_id: + - light.luz_tendedero + data_template: + brightness_pct: "{% if 7 < now().strftime('%H')|int and now().strftime('%H')|int\ + \ < 23 -%}\n 40\n{%- else -%}\n 80\n{%- endif %}\n" + initial_state: 'on' +- id: '1551289639270' + alias: Luz del Tendedero Apagar + initial_state: 'on' + trigger: + - entity_id: binary_sensor.puerta_tendedero + from: 'on' + platform: state + to: 'off' + condition: + - condition: state + entity_id: light.luz_tendedero + state: 'on' + action: + - data: + entity_id: light.luz_tendedero + service: light.turn_off diff --git a/configuration.yaml b/configuration.yaml new file mode 100644 index 0000000..7a1dd02 --- /dev/null +++ b/configuration.yaml @@ -0,0 +1,379 @@ +homeassistant: + # Name of the location where Home Assistant is running + name: Hogar + # Location required to calculate the time the sun rises and sets + latitude: !secret hogar_latitud + longitude: !secret hogar_longitud + # Impacts weather/sunrise data (altitude above sea level in meters) + elevation: !secret hogar_elevacion + # metric for Metric, imperial for Imperial + unit_system: metric + # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones + time_zone: !secret hogar_zonahoraria + # Customization file + customize: !include customize.yaml + packages: !include_dir_named packages + +# Show links to resources in log and frontend +#introduction: + +# Enables the frontend +frontend: + +# Enables configuration UI +config: + +# Uncomment this if you are using SSL/TLS, running in Docker container, etc. +http: + base_url: alacenaha.duckdns.org:8123 + +# Checks for available updates +# Note: This component will send some information about your system to +# the developers to assist with development of Home Assistant. +# For more information, please see: +# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/ +updater: + # Optional, allows Home Assistant developers to focus on popular components. + # include_used_components: true + +# Discover some devices automatically +discovery: + ignore: + - yeelight + +# Allows you to issue voice commands from the frontend in enabled browsers +conversation: + +# Enables support for tracking state changes over time +history: +# Sustituye a history +recorder: + purge_keep_days: 90 + db_url: !secret db_url + +# View all events in a logbook +logbook: + +logger: + default: warning + logs: + miflora: debug + btlewrap: debug + bluepy: debug + homeassistant.components.mqtt: error + homeassistant.components.zwave: error + homeassistant.components.yeelight: debug + +weather: + +# Enables a map showing the location of tracked devices +map: +system_health: +# Track the sun +sun: + +# Sensors +#sensor: + # Weather prediction + # - platform: yr + + #mqtt: !include mqtt.yaml +# Text to speech +tts: + - platform: google + +# Cloud +cloud: + +group: !include groups.yaml +automation: !include automations.yaml +script: !include scripts.yaml + +switch: + - platform: rest + name: "General Luces" + scan_interval: 30 + resource: http://10.10.1.153/relay/0 + body_on: 'turn=on' + body_off: 'turn=off' + timeout: 60 + is_on_template: '{{ value_json.ison == true}}' + headers: + content-type: application/x-www-form-urlencoded + + - platform: rest + name: "General Persianas" + scan_interval: 30 + resource: http://10.10.1.153/relay/1 + body_on: 'turn=on' + body_off: 'turn=off' + timeout : 60 + is_on_template: '{{ value_json.ison == true}}' + headers: + content-type: application/x-www-form-urlencoded + + - platform: rest + name: "General Caldera" + scan_interval: 30 + resource: http://10.10.1.153/relay/2 + body_on: 'turn=on' + body_off: 'turn=off' + timeout : 60 + is_on_template: '{{ value_json.ison == true}}' + headers: + content-type: application/x-www-form-urlencoded + + - platform: rest + name: "Coche Eléctrico" + scan_interval: 30 + resource: http://10.10.1.153/relay/3 + body_on: 'turn=on' + body_off: 'turn=off' + timeout : 60 + is_on_template: '{{ value_json.ison == true}}' + headers: + content-type: application/x-www-form-urlencoded + + - platform: xiaomi_miio + name: Xiaomi Strip 1 + host: 10.10.1.145 + token: fe3b88c2fdf9d129e30c8cd945ed4461 + + - platform: xiaomi_miio + name: Xiaomi Strip 2 + host: 10.10.1.146 + token: 3e1fea7691567cf1d5241f02ebb989ee + + +zwave: + usb_path: /dev/ttyACM1 + + +google_assistant: + project_id: homeassistant-8c53b + api_key: AIzaSyDhRdUJU0pHmxxVP0IYu-BKNKDrf1_ivlM + expose_by_default: true + exposed_domains: + - switch + - light + - media_player + entity_config: + light.yeelight_ceiling_7c49ebae71f9: + expose: true + name: Luz Habitación Estudio + +binary_sensor: + - platform: mqtt + name: "Puerta Entrada" #Puerta de Entrada + payload_on: "A2670A" + payload_off: "A2670E" + device_class: opening + state_topic: "sonoffbridge/tele/RESULT" + value_template: "{{value_json.RfReceived.Data}}" + + - platform: mqtt + name: "Puerta Tendedero" + payload_on: "0D7F0A" + payload_off: "0D7F0E" + device_class: opening + state_topic: "sonoffbridge/tele/RESULT" + value_template: "{{value_json.RfReceived.Data}}" + + - platform: mqtt + name: "Movimiento Habitación Estudio" + payload_on: "2A00BC" + payload_off: "2A00BCoff" + device_class: motion + state_topic: "sonoffbridge/tele/RESULT" + value_template: "{{value_json.RfReceived.Data}}" + off_delay: 8 + + - platform: mqtt + name: "Movimiento Pasillo Habitaciones" + payload_on: "5D559C" + payload_off: "5D559Coff" + device_class: motion + state_topic: "sonoffbridge/tele/RESULT" + value_template: "{{value_json.RfReceived.Data}}" + off_delay: 8 + + - platform: workday + country: ES + province: MAD + workdays: [mon, tue, wed, thu, fri] + +sensor: + - platform: sql + db_url: !secret db_url + queries: + - name: db_size + query: "SELECT (pg_database_size('homeassistant')/1024/1024) as db_size;" + column: db_size + unit_of_measurement: MB + scan_interval: 120 + + - platform: mqtt + name: "Consumo General Luces" + state_topic: "shellies/shelly4pro-061E6E/relay/0/power" + unit_of_measurement: "W" + - platform: mqtt + name: "Consumo General Persianas" + state_topic: "shellies/shelly4pro-061E6E/relay/1/power" + unit_of_measurement: "W" + - platform: mqtt + name: "Consumo General Calefacción" + state_topic: "shellies/shelly4pro-061E6E/relay/2/power" + unit_of_measurement: "W" + - platform: mqtt + name: "Consumo General Coche Eléctrico" + state_topic: "shellies/shelly4pro-061E6E/relay/3/power" + unit_of_measurement: "W" + - platform: mqtt + name: "Energia General Luces" + state_topic: "shellies/shelly4pro-061E6E/relay/0/energy" + unit_of_measurement: "KWh" + value_template: "{{ value | multiply(0.01) | float | round(2)}}" + - platform: mqtt + name: "Energia General Persianas" + state_topic: "shellies/shelly4pro-061E6E/relay/1/energy" + unit_of_measurement: "KWh" + value_template: "{{ value | multiply(0.01) | float | round(2)}}" + - platform: mqtt + name: "Energia General Calefacción" + state_topic: "shellies/shelly4pro-061E6E/relay/2/energy" + unit_of_measurement: "KWh" + value_template: "{{ value | multiply(0.01) | float | round(2)}}" + - platform: mqtt + name: "Energia General Coche Eléctrico" + state_topic: "shellies/shelly4pro-061E6E/relay/3/energy" + unit_of_measurement: "KWh" + value_template: "{{ value | multiply(0.01) | float | round(2)}}" + + #Sensor del horno +# - platform: mqtt +# name: "Consumo Horno Actual" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{value_json['ENERGY'].Power }}" +# qos: 1 +# unit_of_measurement : "W" + +# - platform: mqtt +# name: "Voltaje Horno" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{ value_json['ENERGY'].Voltage }}" +# qos: 1 +# unit_of_measurement : "V" + +# - platform: mqtt +# name: "Amperios Horno" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{ value_json['ENERGY'].Current }}" +# qos: 1 +# unit_of_measurement : "A" + +# - platform: mqtt +# name: "Consumo Horno Hoy" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{ value_json['ENERGY'].Today }}" +# qos: 1 +# unit_of_measurement : "kWh" + +# - platform: mqtt +# name: "Consumo Horno Ayer" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{ value_json['ENERGY'].Yesterday }}" +# qos: 1 +# unit_of_measurement : "kWh" + +# - platform: mqtt +# name: "Consumo Horno Total" +# state_topic: "tele/SonoffHorno/SENSOR" +# value_template: "{{ value_json['ENERGY'].Total }}" +# qos: 1 +# unit_of_measurement : "kWh" + + #Sensor Usos Varios 2 +# - platform: mqtt +# name: "Consumo Usos Varios 2 Actual" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{value_json['ENERGY'].Power }}" +# qos: 1 +# unit_of_measurement : "W" + +# - platform: mqtt +# name: "Voltaje Usos Varios 2" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{ value_json['ENERGY'].Voltage }}" +# qos: 1 +# unit_of_measurement : "V" + +# - platform: mqtt +# name: "Amperios Usos Varios 2" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{ value_json['ENERGY'].Current }}" +# qos: 1 +# unit_of_measurement : "A" + +# - platform: mqtt +# name: "Consumo Usos Varios 2 Hoy" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{ value_json['ENERGY'].Today }}" +# qos: 1 +# unit_of_measurement : "kWh" + +# - platform: mqtt +# name: "Consumo Usos Varios 2 Ayer" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{ value_json['ENERGY'].Yesterday }}" +# qos: 1 +# unit_of_measurement : "kWh" + +# - platform: mqtt +# name: "Consumo Usos Varios 2 Total" +# state_topic: "tele/Sonoffuv2/SENSOR" +# value_template: "{{ value_json['ENERGY'].Total }}" +# qos: 1 +# unit_of_measurement : "kWh" + +light: + - platform: xiaomi_miio + name: Luz Entrada Dormitorio + host: 10.10.1.191 + token: f7a017cf2a7df0f64f3866d091ec24e1 + model: philips.light.downlight + + - platform: xiaomi_miio + name: Luz Habitaciones Pasillo + host: 10.10.1.192 + token: f6743cf3e3639ac42870bed17dfc5fc0 + model: philips.light.downlight + + - platform: xiaomi_miio + name: Luz Estudio Pasillo + host: 10.10.1.193 + token: 7026ea559226f23e1ed3bff25adac20d + model: philips.light.downlight + + - platform: xiaomi_miio + name: Luz Entrada Pasillo + host: 10.10.1.194 + token: 1f7148e6ecadea293937b34565f2035c + model: philips.light.downlight + + - platform: xiaomi_miio + name: Luz Tendedero + host: 10.10.1.195 + token: 7b7b7720161907220116d261372161fb + model: philips.light.downlight + + - platform: yeelight + devices: + 10.10.1.161: + name: Luz Habitacion Estudio + 10.10.1.162: + name: Luz Habitacion Noha + 10.10.1.163: + name: Luz Habitacion Mia + 10.10.1.164: + name: Luz Habitacion Principal + diff --git a/customize.yaml b/customize.yaml new file mode 100644 index 0000000..1bbbba1 --- /dev/null +++ b/customize.yaml @@ -0,0 +1,26 @@ +light.yeelight_ceiling_7c49ebae71f9: + friendly_name: Luz Habitación Estudio +light.yeelight_ceiling_7c49ebb85735: + friendly_name: Luz Habitación Mia +light.yeelight_ceiling_7c49ebb86489: + friendly_name: Luz Habitación Noha +light.yeelight_ceiling3_04cf8c78add6: + friendly_name: Luz Habitación Principal +sun.sun: + friendly_name: Sol +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_current: + friendly_name: Consumo en Amperios +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power: + friendly_name: Consumo en Wattios +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power_factor: + friendly_name: Factor de Potencia +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_voltage: + friendly_name: General Voltaje +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_energy: + friendly_name: Potencia Reactiva +sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_energy_2: + friendly_name: Potencia Activa +switch.light_led_cabecero: + friendly_name: Luz Cabecero Principal + assumed_state: false + icon: mdi:lightbulb diff --git a/groups.yaml b/groups.yaml new file mode 100644 index 0000000..e69de29 diff --git a/packages/broadlink.yaml b/packages/broadlink.yaml new file mode 100644 index 0000000..5d535b6 --- /dev/null +++ b/packages/broadlink.yaml @@ -0,0 +1,10 @@ +switch: + - platform: broadlink + host: 10.10.1.152 + mac: '34:EA:34:E4:6A:2E' + timeout: 15 + switches: + light_led_cabecero: + command_on: 'sgC0AQkKCQkJLAkJCSwJLAgKCQkJLAkJCSwJCQksCQkJKwoAAVkJWwkJCCwJCgksCCwJCgkrCQkKKwkKCAoJKwkKCSsJLAkKCQkJLAkrCQoJCQksCQkJLAkJCSwJCQksCSwICgkJCSwJCggsCQkJLAkJCSwJLAkJCSwJCQkKCCwJCQksCSwJCQorCQoICgksCAoJKworCQoJCQkrCgkJLAkJCSwJCQgsCQABWglaCQoJKwkKCCwJLAkJCSwJCQksCQkJCggsCQkJLAksCQkKCQksCSsJCggKCSwICgksCAoJLAgKCSwILAkJCgkJLAkJCSwJCQksCQkJLAksCAoJKwkKCQkJLAkJCSwJKwkKCSwJCQkJCSwJCggsCSwJCQkKCSsJCQksCQoILAkJCSwJAAFaCVoJCQksCQkJLAkrCQoJKwkKCSsJCgkJCSwJCQksCSsJCgkKCSsJLAkJCQoILQgKCCwJCggsCQoILAksCQkJCQktCQkJLAgKCSwICgksCCwJCggsCQoJCQksCQkJLAgsCQoJLAgKCQkJLAkJCSwJLAgKCQkJLAkJCSwJCQksCQkJLAgABdwAAAAA' + command_off: 'sgCCAQkKCSsJCgkJCSwJCQksCSsJCgkJCSwJLAgKCQkJLAkKCCwJCQksCQkJLAksCAoJCQktCAoJLAkJCSwICgksCSsJCggsCQoICgksCQkJLAgsCQoJKwkKCQkJLAkJCSwJCQksCQkJLAkJCSwJCQksCQkJLAkAAVoIWwkJCSwJCQksCSsJCgkrCQoILAkKCQkJLAkJCSwILAkKCQkJLAksCQkJCQksCQkJLAkJCSwJCggsCSwICgkJCS0JCQksCQkJLAgKCSwILAkKCCwJCgkJCSwJCQkrCSwJCgksCAoJCQksCQkJLAkJCSwJCQksCQkJLAkJCSwJCQksCQABWghbCQkJLAkJCSwJKwkKCSsJCgksCAoJCQksCQkJLAkrCQoJCQksCSwJCQkJCSwJCQksCQoILAkKCCwJLAkJCQoILQkJCSwICgksCAoJLAkrCQoJKwkKCAoJLAkJCSwILAkKCSwICgkJCSwJCQksCQkJLAkJCSwJCQksCQkJLAkJCSwJAAXcAAAAAAAA' + diff --git a/packages/citroen.yaml b/packages/citroen.yaml new file mode 100644 index 0000000..ffc62ed --- /dev/null +++ b/packages/citroen.yaml @@ -0,0 +1,76 @@ +sensor: + + - platform: command_line + command: !secret citroen_status + name: citroen_status + json_attributes: + - signals + - location + - updatedAt + value_template: '' + scan_interval: 300 + + - platform: template + sensors: + citroen_bateria: + friendly_name: 'Citroen Batería' + value_template: >- + {% for signals in states.sensor.citroen_status.attributes.signals -%} + {% if signals.name == "BatteryVoltage" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'V' + citroen_velocidad: + friendly_name: 'Citroen Velocidad' + value_template: >- + {% for signals in states.sensor.citroen_status.attributes.signals -%} + {% if signals.name == "GpsSpeed" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'Km/h' + citroen_combustible: + friendly_name: 'Citroen Gasolina' + value_template: >- + {% for signals in states.sensor.citroen_status.attributes.signals -%} + {% if signals.name == "FuelLevel" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'L' + citroen_kilometros: + friendly_name: 'Citroen Total Km' + value_template: >- + {% for signals in states.sensor.citroen_status.attributes.signals -%} + {% if signals.name == "Odometer" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'km' + citroen_revoluciones: + friendly_name: 'Citroen Revoluciones por Minuto' + value_template: >- + {% for signals in states.sensor.citroen_status.attributes.signals -%} + {% if signals.name == "EngineSpeed" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'tr/min' + citroen_fecha_update: + friendly_name: 'Citroen Actualización' + value_template: "{{ as_timestamp(states.sensor.citroen_status.attributes.updatedAt) | timestamp_custom('%D %-I:%M %P') }}" + citroen_latitud: + friendly_name: 'Citroen Latitud' + value_template: '{{ states.sensor.citroen_status.attributes.location.latitude }}' + citroen_longitud: + friendly_name: 'Citroen Longitud' + value_template: '{{ states.sensor.citroen_status.attributes.location.longitude }}' + +camera: + name: Posición Citroen + platform: generic + still_image_url: !secret camara_citroen + limit_refetch_to_url_change: true + + diff --git a/packages/device_tracker_bluetooth.yaml b/packages/device_tracker_bluetooth.yaml new file mode 100644 index 0000000..1cbce2a --- /dev/null +++ b/packages/device_tracker_bluetooth.yaml @@ -0,0 +1,2 @@ +device_tracker: + - platform: bluetooth_tracker diff --git a/packages/energia.yaml b/packages/energia.yaml new file mode 100644 index 0000000..32acb7f --- /dev/null +++ b/packages/energia.yaml @@ -0,0 +1,73 @@ +sensor: + - platform: sql + db_url: !secret db_url + scan_interval: 600 + queries: + - name: Coste Ayer TDH + query: "SELECT ayer, MAX(avr_day_0_12) as avr_1, MAX(avr_day_12_22) as avr_2, MAX(avr_day_22_23) as avr_3, (MAX(avr_day_0_12)+MAX(avr_day_12_22)+MAX(avr_day_22_23)) as total, MAX(avr_day_full) as TotalFull +FROM +((SELECT DATE(created) as ayer, (AVG(CAST ( state AS numeric ))*12*0.082/1000) AS avr_day_0_12,0 as avr_day_12_22,0 as avr_day_22_23, 0 as avr_day_full + FROM states + WHERE entity_id = 'sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power' + AND state != 'unknown' + AND state != '' + AND CAST(state AS numeric) >= 0 + AND CAST(state AS numeric) <= 7500 + AND DATE(created) = current_date -1 + AND EXTRACT(HOUR from created) between '00' and '11' + GROUP BY DATE(created) + ORDER BY DATE(created)) +UNION +(SELECT DATE(created),0,(AVG(CAST ( state AS numeric ))*10*0.161/1000) AS avr_day_12_22,0,0 + FROM states + WHERE entity_id = 'sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power' + AND state != 'unknown' + AND state != '' + AND CAST(state AS numeric) >= 0 + AND CAST(state AS numeric) <= 7500 + AND DATE(created) = current_date -1 + AND EXTRACT(HOUR from created) between '12' and '21' + GROUP BY DATE(created) + ORDER BY DATE(created)) +UNION +(SELECT DATE(created),0,0, (AVG(CAST ( state AS numeric ))*2*0.082/1000) AS avr_day_23_00, 0 + FROM states + WHERE entity_id = 'sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power' + AND state != 'unknown' + AND state != '' + AND CAST(state AS numeric) >= 0 + AND CAST(state AS numeric) <= 7500 + AND DATE(created) = current_date -1 + AND EXTRACT(HOUR from created) between '22' and '23' + GROUP BY DATE(created) + ORDER BY DATE(created)) +UNION +(SELECT DATE(created),0,0,0, (AVG(CAST ( state AS numeric ))*24*0.139/1000) AS avr_day_full + FROM states + WHERE entity_id = 'sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power' + AND state != 'unknown' + AND state != '' + AND CAST(state AS numeric) >= 0 + AND CAST(state AS numeric) <= 7500 + AND DATE(created) = current_date -1 + GROUP BY DATE(created) + ORDER BY DATE(created)) +) as a +group by ayer;" + column: "total" + unit_of_measurement: € + value_template: "{{ value | round(2) }}" + - name: Coste Ayer TSDH + query: "SELECT DATE(created), (AVG(CAST ( state AS numeric ))*24*0.139/1000) AS total + FROM states + WHERE entity_id = 'sensor.qubino_zmnhtdx_smart_meter_s4_s5_s6_power' + AND state != 'unknown' + AND state != '' + AND CAST(state AS numeric) >= 0 + AND CAST(state AS numeric) <= 7500 + AND DATE(created) = current_date -1 + GROUP BY DATE(created) + ORDER BY DATE(created);" + column: "total" + unit_of_measurement: € + value_template: "{{ value | round(2) }}" diff --git a/packages/kodi_hab_padres.yaml b/packages/kodi_hab_padres.yaml new file mode 100644 index 0000000..a5ea699 --- /dev/null +++ b/packages/kodi_hab_padres.yaml @@ -0,0 +1,6 @@ +media_player: + - platform: kodi + host: 10.10.1.121 + name: Hab. Padres + username: kodi + password: XBMC diff --git a/packages/luzentradapasillo.yaml b/packages/luzentradapasillo.yaml new file mode 100644 index 0000000..9787b5b --- /dev/null +++ b/packages/luzentradapasillo.yaml @@ -0,0 +1,46 @@ +automation: +- alias: Encender Luz Entrada Pasillo Normal + initial_state: 'on' + trigger: + - platform: state + entity_id: binary_sensor.movimiento_entrada_pasillo + to: 'on' + condition: + condition: or + conditions: + - before: sunrise + condition: sun + - after: sunset + condition: sun + action: + - service: homeassistant.turn_on + data: + entity_id: + - light.luz_entrada_pasillo + data_template: + brightness: > + {% if 7 < now().strftime('%H')|int and now().strftime('%H')|int < 23 -%} + 255 + {%- else -%} + 100 + {%- endif %} + - service: timer.start + data: + entity_id: timer.luzentradapasillo + +- alias: Apagar Luz Entrada Pasillo Normal + initial_state: 'on' + trigger: + platform: event + event_type: timer.finished + event_data: + entity_id: timer.luzentradapasillo + action: + service: homeassistant.turn_off + data: + entity_id: + - light.luz_entrada_pasillo + +timer: + luzentradapasillo: + duration: '00:03:05' diff --git a/packages/luzhabitacionestudio.yaml b/packages/luzhabitacionestudio.yaml new file mode 100644 index 0000000..65eef59 --- /dev/null +++ b/packages/luzhabitacionestudio.yaml @@ -0,0 +1,39 @@ +automation: +- alias: Encender Luz Habitación Estudio Normal + initial_state: 'on' + trigger: + - platform: state + entity_id: binary_sensor.movimiento_habitacion_estudio + to: 'on' + condition: + condition: or + conditions: + - before: sunrise + condition: sun + - after: sunset + condition: sun + action: + - service: homeassistant.turn_on + data: + entity_id: + - light.luz_habitacion_estudio + - service: timer.start + data: + entity_id: timer.luzhabitacionestudio + +- alias: Apagar Luz Habitación Estudio Normal + initial_state: 'on' + trigger: + platform: event + event_type: timer.finished + event_data: + entity_id: timer.luzhabitacionestudio + action: + service: homeassistant.turn_off + data: + entity_id: + - light.luz_habitacion_estudio + +timer: + luzhabitacionestudio: + duration: '00:03:00' diff --git a/packages/luzpasillo.yaml b/packages/luzpasillo.yaml new file mode 100644 index 0000000..6f8dbce --- /dev/null +++ b/packages/luzpasillo.yaml @@ -0,0 +1,48 @@ +automation: +- alias: Encender Luz Pasillo Normal + initial_state: 'on' + trigger: + - platform: state + entity_id: binary_sensor.movimiento_pasillo_habitaciones + to: 'on' + condition: + condition: or + conditions: + - before: sunrise + condition: sun + - after: sunset + condition: sun + action: + - service: homeassistant.turn_on + data: + entity_id: + - light.luz_estudio_pasillo + - light.luz_habitaciones_pasillo + data_template: + brightness: > + {% if 7 < now().strftime('%H')|int and now().strftime('%H')|int < 23 -%} + 255 + {%- else -%} + 50 + {%- endif %} + - service: timer.start + data: + entity_id: timer.luzpasillo + +- alias: Apagar Luz Pasillo Normal + initial_state: 'on' + trigger: + platform: event + event_type: timer.finished + event_data: + entity_id: timer.luzpasillo + action: + service: homeassistant.turn_off + data: + entity_id: + - light.luz_estudio_pasillo + - light.luz_habitaciones_pasillo + +timer: + luzpasillo: + duration: '00:00:20' diff --git a/packages/persianas.yaml b/packages/persianas.yaml new file mode 100644 index 0000000..3e3da35 --- /dev/null +++ b/packages/persianas.yaml @@ -0,0 +1,120 @@ +cover: + - platform: mqtt + name: "Persina Habitación Principal" + state_topic: "shellies/shellyswitch25-744b67/roller/0" + command_topic: "shellies/shellyswitch25-744B67/roller/0/command" + position_topic: "shellies/shellyswitch25-744B67/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-744B67/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-744B67/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 + + - platform: mqtt + name: "Persina Habitación Noha" + state_topic: "shellies/shellyswitch25-5DB8BE/roller/0" + command_topic: "shellies/shellyswitch25-5DB8BE/roller/0/command" + position_topic: "shellies/shellyswitch25-5DB8BE/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-5DB8BE/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-5DB8BE/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 + + - platform: mqtt + name: "Persina Habitación Mia" + state_topic: "shellies/shellyswitch25-74595B/roller/0" + command_topic: "shellies/shellyswitch25-74595B/roller/0/command" + position_topic: "shellies/shellyswitch25-74595B/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-74595B/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-74595B/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 + + - platform: mqtt + name: "Persina Habitación Estudio" + state_topic: "shellies/shellyswitch25-74595A/roller/0" + command_topic: "shellies/shellyswitch25-74595A/roller/0/command" + position_topic: "shellies/shellyswitch25-74595A/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-74595A/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-74595A/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 + + - platform: mqtt + name: "Persina Salón Fase Dos" + state_topic: "shellies/shellyswitch25-745590/roller/0" + command_topic: "shellies/shellyswitch25-745590/roller/0/command" + position_topic: "shellies/shellyswitch25-745590/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-745590/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-745590/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 + + - platform: mqtt + name: "Persina Salón Piscina" + state_topic: "shellies/shellyswitch25-74552E/roller/0" + command_topic: "shellies/shellyswitch25-74552E/roller/0/command" + position_topic: "shellies/shellyswitch25-74552E/roller/0/pos" + set_position_topic: "shellies/shellyswitch25-74552E/roller/0/command/pos" + availability_topic: "shellies/shellyswitch25-74552E/online" + state_open: "open" +# state_close: "close" + payload_available: "true" + payload_not_available: "false" + retain: false + optimistic: false + payload_open: "open" + payload_close: "close" + payload_stop: "stop" + position_open: 100 + position_closed: 0 + qos: 0 diff --git a/packages/plantas.yaml_disable b/packages/plantas.yaml_disable new file mode 100644 index 0000000..4118c5e --- /dev/null +++ b/packages/plantas.yaml_disable @@ -0,0 +1,12 @@ +sensor: + - platform: miflora + mac: 'C4:7C:8D:67:5A:AC' + name: Plantas + force_update: true + median: 3 + monitored_conditions: + - moisture + - light + - temperature + - conductivity + - battery diff --git a/packages/purificador.yaml b/packages/purificador.yaml new file mode 100644 index 0000000..e94e0a6 --- /dev/null +++ b/packages/purificador.yaml @@ -0,0 +1,5 @@ +fan: + - platform: xiaomi_miio + host: 10.10.1.173 + token: c7411a8e3b3631f918fe70cba89aa623 + model: zhimi.airpurifier.mc1 diff --git a/packages/smart.yaml b/packages/smart.yaml new file mode 100644 index 0000000..fef61b0 --- /dev/null +++ b/packages/smart.yaml @@ -0,0 +1,76 @@ +sensor: + + - platform: command_line + command: !secret smart_status + name: smart_status + json_attributes: + - signals + - location + - updatedAt + value_template: '' + scan_interval: 300 + + - platform: template + sensors: + smart_bateria: + friendly_name: 'Smart Batería' + value_template: >- + {% for signals in states.sensor.smart_status.attributes.signals -%} + {% if signals.name == "BatteryVoltage" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'V' + smart_velocidad: + friendly_name: 'Smart Velocidad' + value_template: >- + {% for signals in states.sensor.smart_status.attributes.signals -%} + {% if signals.name == "GpsSpeed" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'Km/h' +# smart_combustible: +# friendly_name: 'Smart Gasolina' +# value_template: >- +# {% for signals in states.sensor.smart_status.attributes.signals -%} +# {% if signals.name == "FuelLevel" %} +# {{ signals.value }} +# {% endif %} +# {%- endfor -%} +# unit_of_measurement: 'L' + smart_kilometros: + friendly_name: 'Smart Total Km' + value_template: >- + {% for signals in states.sensor.smart_status.attributes.signals -%} + {% if signals.name == "Odometer" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'km' + smart_revoluciones: + friendly_name: 'Smart Revoluciones por Minuto' + value_template: >- + {% for signals in states.sensor.smart_status.attributes.signals -%} + {% if signals.name == "EngineSpeed" %} + {{ signals.value }} + {% endif %} + {%- endfor -%} + unit_of_measurement: 'tr/min' + smart_fecha_update: + friendly_name: 'Smart Actualización' + value_template: "{{ as_timestamp(states.sensor.smart_status.attributes.updatedAt) | timestamp_custom('%D %-I:%M %P') }}" + smart_latitud: + friendly_name: 'Smart Latitud' + value_template: '{{ states.sensor.smart_status.attributes.location.latitude }}' + smart_longitud: + friendly_name: 'Smart Longitud' + value_template: '{{ states.sensor.smart_status.attributes.location.longitude }}' + +camera: + name: Posición Smart + platform: generic + still_image_url: !secret camara_smart + limit_refetch_to_url_change: true + + diff --git a/packages/sonoff.yaml b/packages/sonoff.yaml new file mode 100644 index 0000000..8d7a50f --- /dev/null +++ b/packages/sonoff.yaml @@ -0,0 +1,21 @@ +automation: + - alias: "Power state on HA start-up" + trigger: + platform: homeassistant + event: start + action: + - service: mqtt.publish + data: + topic: "sonoffs/cmnd/state" + payload: "" + initial_state: 'on' + - alias: "Enable MQTT discovery for all devices" + trigger: + platform: homeassistant + event: start + action: + - service: mqtt.publish + data: + topic: "sonoffs/cmnd/SetOption19" + payload: "1" + initial_state: 'on' diff --git a/packages/telegram_bot.yaml b/packages/telegram_bot.yaml new file mode 100755 index 0000000..ede8184 --- /dev/null +++ b/packages/telegram_bot.yaml @@ -0,0 +1,23 @@ +telegram_bot: + - platform: polling + api_key: !secret telegram_apikey + allowed_chat_ids: + - -396720922 #Esperando al Tren (Isabel) + - -377291891 #HANotificacionesSilvia + - -381626310 #HANotificacionesFamilia + - -377425576 #HANotificacionesDiego + +notify: + - name: Telegram_Diego + platform: telegram + chat_id: -377425576 + - name: Telegram_Silvia + platform: telegram + chat_id: -377291891 + - name: Telegram_Familia + platform: telegram + chat_id: -381626310 + - name: Telegram_Isabel + platform: telegram + chat_id: -396720922 + diff --git a/packages/xee.yaml b/packages/xee.yaml new file mode 100644 index 0000000..5ae274c --- /dev/null +++ b/packages/xee.yaml @@ -0,0 +1,14 @@ +sensor: + - platform: command_line + command: !secret refresh_xee_command + name: refresh_xee + scan_interval: 86400 + json_attributes: + - access_token + - expires_in + value_template: >- + {% if value_json.access_token is defined -%} + Válida hasta: {{ (as_timestamp(now()) + value_json.expires_in) | timestamp_local }} + {%- else -%} + Caducada. + {%- endif -%} diff --git a/scripts.yaml b/scripts.yaml new file mode 100644 index 0000000..88c661e --- /dev/null +++ b/scripts.yaml @@ -0,0 +1,56 @@ +#Broadlink - Humidificiador +apagar_encender_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBgAAABJ5YRORISEhMSEhITERMRExMSETkRNxQ3EjgRFBI3EjgTNxI4EhIRFBEUEBQRExEUEhIRExI4ETkRORM3ETgTNxE5EgAFMAABJ0sRAAxfAAEoShEADF8AASdLEQANBQAAAAAAAAAA +display_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBwAAABKJQSOBMRExISEhITERMRFBISETkSOBI3EzcRFBI3EjgSOBISEhMRORETERMTEhISExIRORI3EhMSNxI4EjgRORI4EgAFLwABJ0sSAAxcAAEnSxEADF0AAShKEgAMXAABJ0sRAAxdAAEnShIADQUAAAAAAAAAAA== +calentador_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBgAAABKJQROREUERMSExETERMSExISEzcTNxE5EzcRExI4ETkTNxETEjgSOBETERQSEhEUEhISOBETEhMRORE4EjgRORI4EQAFMQABKEoSAAxgAAEnSxMADF0AAShKEgANBQAAAAAAAAAA +luz_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABKZQSOBEUEhISExISERQSEhITETgSOBI4ETkRFBE4EjgROREUERMRFBE5ERMRFBETERQSNxI4EjgSExE5ETgTNxI4EQAFMwABJ0sSAAxiAAEoShEADQU= +control_humedad_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABKJUSOBETERQRExITERMRFBETETkSOBE4EjgRFBE4EzcSOBEUEjcSExE5EhIRFBETEhMSNxMSETkSEhI4EzcSOBE4EgAFMQABJ0sRAAxfAAEoShIADQU= +tiempo_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABKJUTNxISEhMRExMTERISFBATEjgRORE5ETkSExA5EjgTNxEUEBQROBI4EhMTERITExERORE5ERMSExE5ETkSNxM3EwAFMAABKEoSAAxhAAEoShEADQU= +niebla_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABKJUSOBAUEhMRExEUERMRFBISEjgRORE5ETgSExE5ETgSOBEUETgSOBI4ERQRExISEhMSOBISERQRExE5ETkRORE4EgAFMQABJ0sRAAxfAAEnSxEADQU= +menos_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABKJUSOBMREhMSEhEUERMRFBETEjgRORI4ETkRExI4ETkSNxITERQRExISEjgSExETEhMRORI3EjgSOBITETgSOBI4EgAFMAABKEsSAAxgAAEoShEADQU= +mas_humidificador: + sequence: + - service: switch.broadlink_send_packet_10_10_1_152 + data: + packet: + - JgBYAAABJ5YSNxMSERMSExISEhMRExITETkROBM3EjgRFBE4EzcSOBITETgSExISEjgSExETERQROBITETkRORISETkSOBI4EQAFMQABJ0sTAAxfAAEoShIADQU= + diff --git a/www/plugins/lovelace-auto-entities b/www/plugins/lovelace-auto-entities new file mode 160000 index 0000000..be13234 --- /dev/null +++ b/www/plugins/lovelace-auto-entities @@ -0,0 +1 @@ +Subproject commit be13234a43fa35b2e345fdd73482c8cd2d709e4e diff --git a/www/plugins/lovelace-card-modder b/www/plugins/lovelace-card-modder new file mode 160000 index 0000000..f3d96f7 --- /dev/null +++ b/www/plugins/lovelace-card-modder @@ -0,0 +1 @@ +Subproject commit f3d96f73f158517acac4d836970e623e498cfccd diff --git a/www/plugins/lovelace-card-tools b/www/plugins/lovelace-card-tools new file mode 160000 index 0000000..deb8e38 --- /dev/null +++ b/www/plugins/lovelace-card-tools @@ -0,0 +1 @@ +Subproject commit deb8e38741b7472cd92c50f69fb417e49ad2cb1d diff --git a/www/plugins/lovelace-fold-entity-row b/www/plugins/lovelace-fold-entity-row new file mode 160000 index 0000000..6d11d3c --- /dev/null +++ b/www/plugins/lovelace-fold-entity-row @@ -0,0 +1 @@ +Subproject commit 6d11d3cc65eb9d35c5f64d5c0139cbf5f7ae31c5 diff --git a/www/plugins/lovelace-layout-card b/www/plugins/lovelace-layout-card new file mode 160000 index 0000000..e0ec2f2 --- /dev/null +++ b/www/plugins/lovelace-layout-card @@ -0,0 +1 @@ +Subproject commit e0ec2f21ad0a0b04c74292707f8a1f3e6c813b30