Boa tarde, deixo aqui a minha idea para um temporizador de cozinha ou do que for preciso, está a funcionar bem mas provavelmente haverá alguém capaz de fazer o mesmo de forma mais simples, contudo deixo aqui a minha contribuição:
primeiro criar um inputbollean:
input_boolean:
alarm_clock_status:
initial: on
criar input_number:
input_number:
alarm_clock_minute:
name: Minutos
icon: mdi:timer
initial: 0
min: 0
max: 120
step: 5
criar 2 scripts para aumentar de 5 em 5 min:
'1583966373784':
alias: +5 minutos
sequence:
- entity_id: input_number.alarm_clock_minute
service: input_number.increment
'1583966408415':
alias: -5 minutos
sequence:
- entity_id: input_number.alarm_clock_minute
service: input_number.decrement
no node-red instalar o node mytimeout atraves de: npm i node-red-contrib-mytimeout
com isto feito atravez do node red as seguntes automaçoes:
Codigo dos nodes:
[
{
"id": "5bb46d8c.7ff464",
"type": "server-state-changed",
"z": "bdaa28be.9968d8",
"name": "Botao -5min",
"server": "3be8359a.800b9a",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "binary_sensor.menos_5_min",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": true,
"x": 110,
"y": 160,
"wires": [
[
"8c55fa15.3af128"
]
]
},
{
"id": "8c55fa15.3af128",
"type": "switch",
"z": "bdaa28be.9968d8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "off",
"vt": "str"
},
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 270,
"y": 160,
"wires": [
[],
[
"3242e7cc.13f418"
]
]
},
{
"id": "3242e7cc.13f418",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "script",
"service": "1583966408415",
"entityId": "",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 480,
"y": 160,
"wires": [
[]
]
},
{
"id": "b3e3901c.35c1f",
"type": "server-state-changed",
"z": "bdaa28be.9968d8",
"name": "on/off timer",
"server": "3be8359a.800b9a",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "input_boolean.alarm_clock_status",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": true,
"x": 100,
"y": 280,
"wires": [
[
"96706e60.0dc93"
]
]
},
{
"id": "96706e60.0dc93",
"type": "switch",
"z": "bdaa28be.9968d8",
"name": "on ?? off ??",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "off",
"vt": "str"
},
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 310,
"y": 280,
"wires": [
[
"fa18b891.9d6b98"
],
[
"80206397.9e621"
]
]
},
{
"id": "80206397.9e621",
"type": "api-current-state",
"z": "bdaa28be.9968d8",
"name": "input_number.alarm_clock_minute",
"server": "3be8359a.800b9a",
"version": 1,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"override_topic": false,
"entity_id": "input_number.alarm_clock_minute",
"state_type": "num",
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"blockInputOverrides": false,
"x": 200,
"y": 400,
"wires": [
[
"5ab25816.7d2078"
]
]
},
{
"id": "5ab25816.7d2078",
"type": "function",
"z": "bdaa28be.9968d8",
"name": "min p/ timer",
"func": "t=msg.payload * 60\nnewMSG = { \"warning\": 0, \"timeout\": t}\nreturn newMSG;",
"outputs": 1,
"noerr": 0,
"x": 110,
"y": 460,
"wires": [
[
"59908242.a5091c"
]
]
},
{
"id": "59908242.a5091c",
"type": "mytimeout",
"z": "bdaa28be.9968d8",
"name": "",
"outtopic": "",
"outsafe": "",
"outwarning": "Warning",
"outunsafe": "off",
"warning": "5",
"timer": "30",
"debug": false,
"ndebug": false,
"ignoreCase": false,
"repeat": false,
"again": false,
"x": 130,
"y": 560,
"wires": [
[
"fc5ad9a9.e7a168",
"51858ebc.f009e",
"2f260794.e3b488"
],
[]
]
},
{
"id": "51858ebc.f009e",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "tts",
"service": "google_say",
"entityId": "media_player.googlehome2032",
"data": "{\"message\":\"o temporizador chegou ao fim\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 410,
"y": 540,
"wires": [
[]
]
},
{
"id": "a47c1444.4150b8",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 440,
"wires": [
[
"f26351c3.19363"
]
]
},
{
"id": "38b6aee0.9df982",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 440,
"wires": [
[
"a47c1444.4150b8"
],
[]
]
},
{
"id": "f26351c3.19363",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 480,
"wires": [
[
"725b8289.3e0b9c"
],
[]
]
},
{
"id": "c1de1a47.1a6f58",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 520,
"wires": [
[
"315f5064.91bd8"
],
[]
]
},
{
"id": "f0e66411.1670b8",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 560,
"wires": [
[
"a006bdc6.64968"
],
[]
]
},
{
"id": "dd2183df.6ccbd",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 600,
"wires": [
[
"9bdfba15.705ea8"
],
[]
]
},
{
"id": "b15eb6c8.9bf848",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 640,
"wires": [
[
"73d87a90.8ee894"
],
[]
]
},
{
"id": "56c8c1b4.0f1ac",
"type": "stoptimer",
"z": "bdaa28be.9968d8",
"duration": "1",
"units": "Second",
"payloadtype": "num",
"payloadval": "0",
"name": "",
"x": 640,
"y": 680,
"wires": [
[
"96f762fe.4ab56"
],
[]
]
},
{
"id": "fc5ad9a9.e7a168",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "input_boolean",
"service": "turn_off",
"entityId": "input_boolean.alarm_clock_status",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 360,
"y": 600,
"wires": [
[]
]
},
{
"id": "fa18b891.9d6b98",
"type": "function",
"z": "bdaa28be.9968d8",
"name": "Cancelar o timer",
"func": "{\n msg.payload = { \"payload\": \"cancel\" };\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 500,
"y": 280,
"wires": [
[
"59908242.a5091c"
]
]
},
{
"id": "85404376.3330e",
"type": "server-state-changed",
"z": "bdaa28be.9968d8",
"name": "Botao -5min",
"server": "3be8359a.800b9a",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "binary_sensor.sart_timer",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": true,
"x": 110,
"y": 220,
"wires": [
[
"6b038610.2f1898"
]
]
},
{
"id": "6b038610.2f1898",
"type": "switch",
"z": "bdaa28be.9968d8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "off",
"vt": "str"
},
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 270,
"y": 220,
"wires": [
[],
[
"c90e644e.d29da8"
]
]
},
{
"id": "c90e644e.d29da8",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "input_boolean",
"service": "toggle",
"entityId": "input_boolean.alarm_clock_status",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 470,
"y": 220,
"wires": [
[]
]
},
{
"id": "725b8289.3e0b9c",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 480,
"wires": [
[
"c1de1a47.1a6f58"
]
]
},
{
"id": "315f5064.91bd8",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 520,
"wires": [
[
"f0e66411.1670b8"
]
]
},
{
"id": "a006bdc6.64968",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 560,
"wires": [
[
"dd2183df.6ccbd"
]
]
},
{
"id": "9bdfba15.705ea8",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 600,
"wires": [
[
"b15eb6c8.9bf848"
]
]
},
{
"id": "73d87a90.8ee894",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 640,
"wires": [
[
"56c8c1b4.0f1ac"
]
]
},
{
"id": "96f762fe.4ab56",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 820,
"y": 680,
"wires": [
[]
]
},
{
"id": "2f260794.e3b488",
"type": "api-call-service",
"z": "bdaa28be.9968d8",
"name": "Luz TV ",
"server": "3be8359a.800b9a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "toggle",
"entityId": "light.luz_da_televisao, light.tomada_bancada",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 460,
"y": 440,
"wires": [
[
"38b6aee0.9df982"
]
]
},
{
"id": "3be8359a.800b9a",
"type": "server",
"z": "",
"name": "Home Assistant"
}
]
vou deixar apenas alguns nodes pois os que estão em falta são identicos aos que aqui deixo:
Breve explicação:
ao chegar ao fim o temporizador vai me fazer piscar os leds da cozinha e os leds do movel da tv, assim como o meu google home mini vai dizer"O temporizador chegou ao fim", assim como voltar a colocar o estado do temporizador em Desligado.
Feito isto resta apenas fazer Deploy e deverá funcionar conforme funciona comigo .
Acrescento também todo o projeto de hardware que utilizei para ter um temporizador fisico na cozinha para ajudar nos cozinhados
Usei :
-1nodemcu
-1lcd SSD1306 128x64
-2pushbutton
-1botão fim de curso
-jumperwires
-impressao 3d
Configuração no esphome:
esphome:
name: lcd
platform: ESP8266
board: esp01_1m
wifi:
ssid: NOMEREDEWIRELESS
password: PASSWORDWIFI
fast_connect: True
api:
reboot_timeout: 60s
ota:
logger:
i2c:
sda: GPIO5
scl: GPIO4
sensor:
- platform: homeassistant
id: temporizador
entity_id: input_number.alarm_clock_minute
- platform: homeassistant
id: inside_temperature
entity_id: sensor.temperatura_exterior
internal: true
- platform: homeassistant
id: outside_temperature
entity_id: sensor.temperatura_sala
internal: true
time:
- platform: homeassistant
id: esptime
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: GPIO16
address: 0x3C
lambda: |-
if (id(temporizador_status).state) {
it.print(48, 19, id(font5), " : ligado");
} else {
it.print(48, 19, id(font5), " : desligado");
}
it.printf(10, 10, id(font4), ("Temporizador de: "));
it.printf(12, 24, id(font5), "%.0f min", id(temporizador).state);
// Print time in HH:MM format
it.strftime(0, 60, id(font2), TextAlign::BASELINE_LEFT, "%H:%M", id(esptime).now());
it.printf(127, 33, id(font3), TextAlign::TOP_RIGHT , "%.1f°", id(inside_temperature).state);
it.printf(127, 60, id(font3), TextAlign::BASELINE_RIGHT , "%.1f°", id(outside_temperature).state);
font:
- file: 'ARIALI.ttf'
id: font1
size: 8
- file: 'ARIALI.ttf'
id: font2
size: 22
- file: 'ARIALI.ttf'
id: font3
size: 14
- file: 'ARIALI.ttf'
id: font4
size: 11
- file: 'ARIALI.ttf'
id: font5
size: 12
switch:
- platform: gpio
name: "Relay"
pin: GPIO14
binary_sensor:
- platform: homeassistant
id: temporizador_status
entity_id: input_boolean.alarm_clock_status
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: False
name: "Mais_5_min"
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: False
name: "Menos_5_min"
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: False
name: "Sart-timer"
Desculpem pelo post tão longo e provavelmente confuso, pois confesso que não tenho muito jeito para toturiais , mas tentei o meu melhor
Alguma duvida estou ao dispor.
Obrigado a todos os que contribuem para esta comunidade pois é onde tenho aprendido quase tudo o que tenho implementado e obrigado a todos os que me ajudaram atraves do discord
Bom continuação e bons projetos.
um Abraço
Luís