Home Assistant ESP32 Robotti-imurin käynnistys releellä
ESP32n koodi:
esphome:
name: robot2
esp32:
board: mhetesp32minikit
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "T8lbN/mj+xxJcGRnYcdVCWDh4aGOUBKAA+1y8+ut8wM="
ota:
- platform: esphome
password: "f76aa4ecb929327969ea7c0567839087"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.110
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Robot2 Fallback Hotspot"
password: "5Lf8XVYmqCl4"
captive_portal:
switch:
- platform: gpio
name: "KYTKINR2"
pin: 16
inverted: False
restore_mode: RESTORE_DEFAULT_OFF
Imurin automaatiot:
- id: '1742839773020'
alias: Robot 2 Start to vacum
description: ''
triggers:
- trigger: state
entity_id:
- input_button.start_vacuum
from:
conditions: []
actions:
- sequence:
- type: turn_on
device_id: f46a1851c8924e532596ac5cfc4f8356
entity_id: 7dba5e29c23b5cde41d06ef8e28ff155
domain: switch
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.kytkinr2
mode: single
- id: '1742840644556'
alias: Robot 2 time to clean
description: ''
triggers:
- trigger: time
at: input_datetime.robot_2_time
conditions:
- condition: template
value_template: '{{ now().weekday() in [3, 5] }}'
actions:
- action: automation.trigger
metadata: {}
data:
skip_condition: true
target:
entity_id: automation.robot_2_start_to_vacum
mode: single
Home Assistant ESP32 Liesituuletin
Huomasin jälkeenpäin, että sisääntulot on paras eristää optisesti. Liesikuvun rajakytkin ehti rikkoa suoraan kytketyn inputin, vaikka painike toimi moitteetta. Syynä on ilmeisesti mikrokytkimen huono suojaus ja siitä syntyvät ylijännitepiikit; pelkkä pulldown-vastus ei auttanut. Lisäsin sisääntulojen eteen releet, eikä häiriö enää pääse vaurioittamaan elektroniikkaa. Laitan myöhemmin kuvan kytkennästä.
ESP32n koodi:
esphome:
name: liesituuletin
friendly_name: Liesituuletin
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "wb9G2GeoRdi0f6yKWphQqolwfEqhGLkw3Ar9pFWo0Uk="
ota:
- platform: esphome
password: "8751b2228cd287410e301b0aa7b91460"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.112
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Liesituuletin Fallback Hotspot"
password: "dlRviN1IILuN"
captive_portal:
switch:
- platform: gpio
name: "LT-Valo"
pin: 32
inverted: False
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "LT-T1"
pin: 33
inverted: False
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "LT-T2"
pin: 25
inverted: False
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
name: "LT-T3"
pin: 26
inverted: False
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
- platform: gpio
pin:
number: 19
mode: INPUT_PULLUP
name: "Huuva"
device_class: opening
filters:
- invert:
- delayed_on: 50ms
- delayed_off: 50ms
- platform: gpio
pin:
number: 5
mode: INPUT_PULLUP
name: "Power"
device_class: opening
filters:
- invert:
- delayed_on: 50ms
- delayed_off: 50ms
sensor:
- platform: dht
pin: 21
model: DHT22
temperature:
name: "Lämpötila Huuva"
humidity:
name: "Kosteus Huuva"
update_interval: 6s
Liesituulettimen Automaatiot:
- id: '1745089202276'
alias: LIESI - Valo
description: ''
triggers:
- type: opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
trigger: device
- type: not_opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
trigger: device
conditions: []
actions:
- if:
- type: is_open
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
then:
- type: turn_on
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: a01b8a72147e981776abc67366f8f237
domain: switch
else:
- type: turn_off
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: a01b8a72147e981776abc67366f8f237
domain: switch
mode: single
- id: '1745091641469'
alias: LIESI - Syötön päälle laitto
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.liesituuletin_huuva
from:
- trigger: state
entity_id:
- timer.liesi_aika
to: idle
- type: opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: 7d55476b80cf26df67250d12886baa9d
domain: binary_sensor
trigger: device
- type: not_opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: 7d55476b80cf26df67250d12886baa9d
domain: binary_sensor
trigger: device
conditions: []
actions:
- if:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.liesituuletin_huuva
state: 'on'
- type: is_temperature
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: f57c06e691a2238beff9a2ecafa6cf2d
domain: sensor
below: 80
- condition: or
conditions:
- condition: state
entity_id: timer.liesi_aika
state: active
- type: is_open
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: 7d55476b80cf26df67250d12886baa9d
domain: binary_sensor
then:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.liesi
else:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.liesi
mode: single
- id: '1745091959952'
alias: LIESI - TIMERI
description: ''
triggers:
- type: opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
trigger: device
conditions: []
actions:
- action: timer.start
metadata: {}
data: {}
target:
entity_id: timer.liesi_aika
mode: single
- id: '1745093289166'
alias: LIESI - Kokkaaminen liian kallista, ylilämpö tai PALO
description: ''
triggers:
- trigger: state
entity_id:
- sensor.nordpool_kwh_fi_eur_10_10_0255
from:
- trigger: state
entity_id:
- sensor.liesituuletin_l_mp_tila_huuva
conditions: []
actions:
- if:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.nordpool_kwh_fi_eur_10_10_0255
above: 0.2
- type: is_temperature
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: f57c06e691a2238beff9a2ecafa6cf2d
domain: sensor
above: 60
- condition: and
conditions:
- type: is_temperature
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: f57c06e691a2238beff9a2ecafa6cf2d
domain: sensor
above: 60
- type: is_humidity
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: ab2fcf8c37206288024c8462112f52bf
domain: sensor
below: 1
alias: PALO
then:
- action: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
entity_id:
- automation.liesi_paalle_laitto
- automation.liesi_timeri
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.liesi
else:
- action: automation.turn_on
metadata: {}
data: {}
target:
entity_id:
- automation.liesi_paalle_laitto
- automation.liesi_timeri
mode: single
- id: '1234567890'
alias: LIESI - LT1-3
description: Kytkee tuuletinnopeudet tarkkojen kosteustasojen mukaan
triggers:
- entity_id: sensor.liesituuletin_kosteus_huuva
trigger: state
- type: opened
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
trigger: device
conditions: []
actions:
- if:
- type: is_open
condition: device
device_id: 1bec4ae8ee9a09c1148d7e626234df49
entity_id: cf2a5d78b221d1c674e4e7bc65f11d23
domain: binary_sensor
then:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.liesituuletin_kosteus_huuva
below: 48.9
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.liesituuletin_lt_t1
- switch.liesituuletin_lt_t2
- switch.liesituuletin_lt_t3
- conditions:
- condition: numeric_state
entity_id: sensor.liesituuletin_kosteus_huuva
above: 49
below: 69.9
sequence:
- target:
entity_id: switch.liesituuletin_lt_t1
action: switch.turn_on
data: {}
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.liesituuletin_lt_t2
- switch.liesituuletin_lt_t3
- conditions:
- condition: numeric_state
entity_id: sensor.liesituuletin_kosteus_huuva
above: 70
below: 89.9
sequence:
- target:
entity_id: switch.liesituuletin_lt_t2
action: switch.turn_on
data: {}
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.liesituuletin_lt_t1
- switch.liesituuletin_lt_t3
- conditions:
- condition: numeric_state
entity_id: sensor.liesituuletin_kosteus_huuva
above: 90
sequence:
- target:
entity_id: switch.liesituuletin_lt_t3
action: switch.turn_on
data: {}
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.liesituuletin_lt_t1
- switch.liesituuletin_lt_t2
else:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id:
- switch.liesituuletin_lt_t2
- switch.liesituuletin_lt_t1
- switch.liesituuletin_lt_t3
mode: single
Home Assistant ESP32 Liesituuletin ilman assistanttia Standalone
Tällä liesituuletin toimii ilman Home Assistanttia. Eli:
- Liesituuletin menee kosteuden mukaan eri asetuksiin
- Valo menee päälle, kun huuvan aukaisee ja menee pois päältä 60 minuutin päästä
- Lieden syöttö kannattaa tässä laittaa päälle, kun valo on päällä & huuva on auki & lämpötila on alle 50
- Tai jos haluat helpottaa asiaa, niin lieden syöttö on silloin päällä, kun valo on päällä.
esphome:
name: heatmoisture32
friendly_name: HeatMoisture32
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "sxMeMDktASd3HbXHg2+vI/9JgA7p4oJ7sgck5WV5s0Q="
ota:
- platform: esphome
password: "5d16be6948890fbcb045b4bbc3d34695"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.116
gateway: 192.168.1.1
subnet: 255.255.255.0
ap:
ssid: "Heatmoisture32 Fallback Hotspot"
password: "pogulGFhDJuj"
captive_portal:
# --- Muokkaa näitä arvoja yhdestä paikasta ---
globals:
- id: temp_threshold
type: float
initial_value: '21.0'
- id: humidity_threshold
type: float
initial_value: '60.0'
- id: temp_hysteresis
type: float
initial_value: '0.1'
- id: humidity_hysteresis
type: float
initial_value: '0.1'
# ------------------------------------------------
switch:
- platform: gpio
name: "vara"
pin: 17
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: vara_switch
- platform: gpio
name: "Kompura"
pin: 15
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: kompura_switch
- platform: gpio
name: "Heat"
pin: 18
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: heat_switch
- platform: gpio
name: "Start"
pin: 19
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: start_switch
- platform: template
name: "EN"
id: en_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
sensor:
- platform: dht
pin: 21
model: DHT22
update_interval: 6s
temperature:
id: lampotila_HM
name: "Lämpötila HM"
humidity:
id: kosteus_HM
name: "Kosteus HM"
interval:
- interval: 6s
then:
- lambda: |-
const float temp = id(lampotila_HM).state;
const float hum = id(kosteus_HM).state;
const bool valid_temp = !isnan(temp);
const bool valid_hum = !isnan(hum);
if (!id(en_switch).state) {
id(start_switch).turn_off();
id(kompura_switch).turn_off();
id(heat_switch).turn_off();
return;
}
// HEAT: hysteresis
if (valid_temp) {
if (temp < (id(temp_threshold) - id(temp_hysteresis))) {
id(heat_switch).turn_on();
} else if (temp >= id(temp_threshold)) {
id(heat_switch).turn_off();
}
} else {
id(heat_switch).turn_off();
}
// KOMPURA: hysteresis
if (valid_hum) {
if (hum > (id(humidity_threshold) + id(humidity_hysteresis))) {
id(kompura_switch).turn_on();
} else if (hum <= id(humidity_threshold)) {
id(kompura_switch).turn_off();
}
} else {
id(kompura_switch).turn_off();
}
// START: päälle vain jos molemmat anturit kelvollisia ja HEAT tai KOMPURA on päällä
if (valid_temp && valid_hum && (id(heat_switch).state || id(kompura_switch).state)) {
id(start_switch).turn_on();
} else {
id(start_switch).turn_off();
}
Home Assistant ESP32, kosteuden poistaja ja lämmitin. Automaatio ESP:ssä ja lupa HomeAssistantista.
ESP32 wroom
esphome:
name: heatmoisture32
friendly_name: HeatMoisture32
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "sxMeMDktASd3HbXHg2+vI/9JgA7p4oJ7sgck5WV5s0Q="
ota:
- platform: esphome
password: "5d16be6948890fbcb045b4bbc3d34695"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.116
gateway: 192.168.1.1
subnet: 255.255.255.0
ap:
ssid: "Heatmoisture32 Fallback Hotspot"
password: "pogulGFhDJuj"
captive_portal:
# --- Muokkaa näitä arvoja yhdestä paikasta ---
globals:
- id: temp_threshold
type: float
initial_value: '21.0'
- id: humidity_threshold
type: float
initial_value: '60.0'
- id: temp_hysteresis
type: float
initial_value: '0.1'
- id: humidity_hysteresis
type: float
initial_value: '0.1'
# ------------------------------------------------
switch:
- platform: gpio
name: "vara"
pin: 17
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: vara_switch
- platform: gpio
name: "Kompura"
pin: 15
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: kompura_switch
- platform: gpio
name: "Heat"
pin: 18
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: heat_switch
- platform: gpio
name: "Start"
pin: 19
inverted: True
restore_mode: RESTORE_DEFAULT_OFF
id: start_switch
- platform: template
name: "EN"
id: en_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
sensor:
- platform: dht
pin: 21
model: DHT22
update_interval: 6s
temperature:
id: lampotila_HM
name: "Lämpötila HM"
humidity:
id: kosteus_HM
name: "Kosteus HM"
interval:
- interval: 6s
then:
- lambda: |-
const float temp = id(lampotila_HM).state;
const float hum = id(kosteus_HM).state;
const bool valid_temp = !isnan(temp);
const bool valid_hum = !isnan(hum);
if (!id(en_switch).state) {
id(start_switch).turn_off();
id(kompura_switch).turn_off();
id(heat_switch).turn_off();
return;
}
// HEAT: hysteresis
if (valid_temp) {
if (temp < (id(temp_threshold) - id(temp_hysteresis))) {
id(heat_switch).turn_on();
} else if (temp >= id(temp_threshold)) {
id(heat_switch).turn_off();
}
} else {
id(heat_switch).turn_off();
}
// KOMPURA: hysteresis
if (valid_hum) {
if (hum > (id(humidity_threshold) + id(humidity_hysteresis))) {
id(kompura_switch).turn_on();
} else if (hum <= id(humidity_threshold)) {
id(kompura_switch).turn_off();
}
} else {
id(kompura_switch).turn_off();
}
// START: päälle vain jos molemmat anturit kelvollisia ja HEAT tai KOMPURA on päällä
if (valid_temp && valid_hum && (id(heat_switch).state || id(kompura_switch).state)) {
id(start_switch).turn_on();
} else {
id(start_switch).turn_off();
}
Sitten pitää antaa ESP:een EN-switchille vain käsky HomeAssistantista, että se voi mennä päälle. Itse tein vain automaation, että kun sähkön hinta on kaikkinensa alle 0,15 senttiä, niin laite saa mennä päälle.
- id: '1761507912269'
alias: Kylpyhuoneen HM
description: ''
triggers:
- trigger: state
entity_id:
- sensor.nordpool_kwh_fi_eur_10_10_0255
conditions: []
actions:
- if:
- condition: numeric_state
entity_id: sensor.nordpool_kwh_fi_eur_10_10_0255
below: 0.15
then:
- type: turn_on
device_id: b00e27d77c9db2aa7f59fdbf30a7ef90
entity_id: a9b3d54df472cb0b4e12e6271041a1d7
domain: switch
else:
- type: turn_off
device_id: b00e27d77c9db2aa7f59fdbf30a7ef90
entity_id: a9b3d54df472cb0b4e12e6271041a1d7
domain: switch
mode: single
- id: '1761774163581'
alias: Restart
description: ''
triggers:
- trigger: time
at: '23:30:00'
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
conditions: []
actions:
- action: hassio.host_reboot
metadata: {}
data: {}
mode: single
Home Assistant Kello
Laita Configuration.yaml tiedostoon, niin saat kellon toimimaan:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
Home Assistant sähkön kustannussensori
Tällä saadaan päiväsähkö, yösähkö, ALV ja sähkön marginaali:
template:
- sensor:
- name: "Hetkellinen sähkön kustannus"
unit_of_measurement: "€/h"
state: >
{% set alv_kerroin = (states('input_number.alv') | float(25.5)) / 100 + 1 %}
{% set hinta = (states('sensor.nordpool_kwh_fi_eur_3_10_0') | float(0)) * alv_kerroin %}
{% set teho = states('sensor.p1_meter_power') | float(0) %}
{% set siirtohinta = states('input_number.yosahko') | float(0.035)
if now().hour >= 22 or now().hour < 6
else states('input_number.paivasahko') | float(0.045) %}
{% set marginaalihinta = (states('input_number.sahkon_marginaalihinta') | float(0)) * alv_kerroin %}
{{ ((hinta + siirtohinta + marginaalihinta) * teho) | round(4) }}
icon: mdi:currency-eur

Home Assistant APEX-kortti 48h Nordpool näkymä
type: custom:apexcharts-card
graph_span: 48h
apex_config:
chart:
height: 170px
show:
last_updated: true
experimental:
color_threshold: true
header:
title: NordPool+Siirto/kWh 48 h
show: true
show_states: true
colorize_states: true
span:
start: day
now:
show: true
label: Nyt
series:
- entity: sensor.nordpool_kwh_fi_eur_10_10_0255
show:
extremas: true
in_header: raw
header_color_threshold: true
type: column
data_generator: |
const today = entity.attributes.raw_today.map((start, index) => {
return [new Date(start["start"]).getTime(), Math.round(entity.attributes.raw_today[index]["value"] * 1000) / 1000];
});
const tomorrow = entity.attributes.raw_tomorrow
? entity.attributes.raw_tomorrow.map((start, index) => {
return [new Date(start["start"]).getTime(), Math.round(entity.attributes.raw_tomorrow[index]["value"] * 1000) / 1000];
})
: [];
return [...today, ...tomorrow];
float_precision: 3
color_threshold:
- value: 0
color: darkgreen
opacity: 1
- value: 0.1
color: goldenrod
- value: 0.32
color: darkred
yaxis:
- id: Hinta
min: ~0
decimals: 2
align_to: 0.05
show: true
Home Assistant RPI_GPIO HAT Raspberry pi
Tässä Raspberry pi:n 8 releiselle boardille
switch:
- platform: rpi_gpio
switches:
- port: 5
name: "KIUAS"
invert_logic: true
- port: 6
name: "LIESI"
invert_logic: true
- port: 13
name: "3-VAIHEPISTORASIA"
invert_logic: true
- port: 16
name: "ET 6 kW"
invert_logic: true
- port: 19
name: "ET 5,1 kW"
invert_logic: true
- port: 20
name: "ET 3,6 kWy"
invert_logic: true
- port: 21
name: "LVV"
invert_logic: true
- port: 26
name: "Öljypoltin"
invert_logic: true
Home Assistant Kustannussensori
Tässä templetti jossa yhdistetään kaikki kulut
template:
- sensor:
- name: "Hetkellinen sähkön kustannus"
unit_of_measurement: "€/h"
state: >
{% set alv_kerroin = (states('input_number.alv') | float(25.5)) / 100 + 1 %}
{% set hinta = (states('sensor.nordpool_kwh_fi_eur_3_10_0') | float(0)) * alv_kerroin %}
{% set teho = states('sensor.p1_meter_power') | float(0) %}
{% set siirtohinta = states('input_number.yosahko') | float(0.035)
if now().hour >= 22 or now().hour < 6
else states('input_number.paivasahko') | float(0.045) %}
{% set marginaalihinta = (states('input_number.sahkon_marginaalihinta') | float(0)) * alv_kerroin %}
{{ ((hinta + siirtohinta + marginaalihinta) * teho) | round(4) }}
icon: mdi:currency-eur
Silloin saat tuon uuden Hetkellisen sähkön kustannuksen ja luo nuo 4 eri helpperiä, että saat numerot templateen.
– input_number.paivasahko
– input_number.yosahko
– input_number.alv
– input_number.sahkon_marginaalihinta

