Configuración Inicial

This commit is contained in:
dfcarvajal
2019-04-17 09:36:19 +00:00
commit 2d46ec2369
26 changed files with 1149 additions and 0 deletions

10
packages/broadlink.yaml Normal file
View File

@@ -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'

76
packages/citroen.yaml Normal file
View File

@@ -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

View File

@@ -0,0 +1,2 @@
device_tracker:
- platform: bluetooth_tracker

73
packages/energia.yaml Normal file
View File

@@ -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) }}"

View File

@@ -0,0 +1,6 @@
media_player:
- platform: kodi
host: 10.10.1.121
name: Hab. Padres
username: kodi
password: XBMC

View File

@@ -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'

View File

@@ -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'

48
packages/luzpasillo.yaml Normal file
View File

@@ -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'

120
packages/persianas.yaml Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,5 @@
fan:
- platform: xiaomi_miio
host: 10.10.1.173
token: c7411a8e3b3631f918fe70cba89aa623
model: zhimi.airpurifier.mc1

76
packages/smart.yaml Normal file
View File

@@ -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

21
packages/sonoff.yaml Normal file
View File

@@ -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'

23
packages/telegram_bot.yaml Executable file
View File

@@ -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

14
packages/xee.yaml Normal file
View File

@@ -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 -%}