Closed jolmav closed 3 years ago
Hola,
No estoy seguro si esto puede ayudar aquí o no. Yo he hecho una automatización con NodeRed de algo bastante parecido (al menos a la primera parte de la automatización).
En mi caso he usado el nodo schedex
. La verdad es que en estos momentos no sé si venía instalado o lo agregué yo, ya que estuve probando con varios nodos como el big timer
, sun events
y alguno lo añadí manualmente. Para mi este fue el más sencillo de utilizar. Pero estaría bien un vídeo comparando los distintos tipos y las ventajas de cada uno :pray:
Esta es mi automatización: Consiste en encender la luz cuando oscurezca hasta las 23:00 y encenderla a las 7:00 hasta que salga el sol (en este último caso solo entre semana)
Explicación:
schedex
tenemos que poner la latitud y longintud y después tiene varios parámetros para disparar los eventos, también tenemos varios tipos de "puesta de sol" (justo cuando se pone el sol, o ciertos grados después de que se ponga, etc.)
Switch:
Por ultimo hacemos la acción:
Este es el ćodigo, habrá que sustituir la latitud y longintud por los correctos, si alguien ve algún otro dato sensible que deba de eliminar, decidmelo, please!
[
{
"id": "65822a0d.99c154",
"type": "tab",
"label": "Light - Front door",
"disabled": false,
"info": ""
},
{
"id": "bb54ad1f.38351",
"type": "api-call-service",
"z": "65822a0d.99c154",
"name": "",
"server": "39c376ab.0cd02a",
"version": 1,
"debugenabled": false,
"service_domain": "telegram_bot",
"service": "send_message",
"entityId": "",
"data": "{\"message\":\"Light On\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 920,
"y": 240,
"wires": [
[]
]
},
{
"id": "e3be6e15.f73d3",
"type": "api-call-service",
"z": "65822a0d.99c154",
"name": "",
"server": "39c376ab.0cd02a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_on",
"entityId": "light.front_door",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 870,
"y": 320,
"wires": [
[]
]
},
{
"id": "19570b6.60b4df5",
"type": "switch",
"z": "65822a0d.99c154",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 610,
"y": 400,
"wires": [
[
"bb54ad1f.38351",
"e3be6e15.f73d3"
],
[
"a61681bf.7e433",
"ef6ad824.10a818"
]
]
},
{
"id": "a61681bf.7e433",
"type": "api-call-service",
"z": "65822a0d.99c154",
"name": "",
"server": "39c376ab.0cd02a",
"version": 1,
"debugenabled": false,
"service_domain": "telegram_bot",
"service": "send_message",
"entityId": "",
"data": "{\"message\":\"Light Off\"}",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 920,
"y": 560,
"wires": [
[]
]
},
{
"id": "ef6ad824.10a818",
"type": "api-call-service",
"z": "65822a0d.99c154",
"name": "",
"server": "39c376ab.0cd02a",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_off",
"entityId": "light.front_door",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 870,
"y": 480,
"wires": [
[]
]
},
{
"id": "e2421ea4.aaa74",
"type": "schedex",
"z": "65822a0d.99c154",
"name": "",
"passthroughunhandled": false,
"suspended": false,
"lat": "40",
"lon": "0",
"ontime": "dusk",
"ontopic": "",
"onpayload": "on",
"onoffset": 0,
"onrandomoffset": 0,
"offtime": "23:00",
"offtopic": "",
"offpayload": "off",
"offoffset": 0,
"offrandomoffset": 0,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": true,
"sun": true,
"x": 110,
"y": 280,
"wires": [
[
"4f98301a.64b428"
]
]
},
{
"id": "a45a1358.d9381",
"type": "schedex",
"z": "65822a0d.99c154",
"name": "",
"passthroughunhandled": false,
"suspended": false,
"lat": "40",
"lon": "0",
"ontime": "7:00",
"ontopic": "",
"onpayload": "on",
"onoffset": 0,
"onrandomoffset": 0,
"offtime": "sunrise",
"offtopic": "",
"offpayload": "off",
"offoffset": 0,
"offrandomoffset": 0,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": false,
"sun": false,
"x": 120,
"y": 540,
"wires": [
[
"4846cc31.cf19f4"
]
]
},
{
"id": "4f98301a.64b428",
"type": "api-current-state",
"z": "65822a0d.99c154",
"name": "Sunset enabled",
"server": "39c376ab.0cd02a",
"version": 1,
"outputs": 2,
"halt_if": "true",
"halt_if_type": "bool",
"halt_if_compare": "is",
"override_topic": false,
"entity_id": "input_boolean.light_sunset_front_door",
"state_type": "habool",
"state_location": "",
"override_payload": "none",
"entity_location": "",
"override_data": "none",
"blockInputOverrides": false,
"x": 380,
"y": 280,
"wires": [
[
"19570b6.60b4df5"
],
[]
]
},
{
"id": "4846cc31.cf19f4",
"type": "api-current-state",
"z": "65822a0d.99c154",
"name": "Sunrise enabled",
"server": "39c376ab.0cd02a",
"version": 1,
"outputs": 2,
"halt_if": "true",
"halt_if_type": "bool",
"halt_if_compare": "is",
"override_topic": false,
"entity_id": "input_boolean.light_sunrise_front_door",
"state_type": "habool",
"state_location": "",
"override_payload": "none",
"entity_location": "",
"override_data": "none",
"blockInputOverrides": false,
"x": 380,
"y": 540,
"wires": [
[
"19570b6.60b4df5"
],
[]
]
},
{
"id": "39c376ab.0cd02a",
"type": "server",
"z": "",
"name": "Home Assistant",
"addon": true
}
]
Como decía antes, no sé si esto puede ayudar a alguien, la verdad es que soy bastante novato en NodeRed y Home Assitatant o sea que si alguien ve algo raro en todo esto que he hecho que me lo comente.
Muchas gracias por el repo y el canal Jota!
Hecho. Muchas gracias por la petición y a @jjcarrion por el curro que se ha pegado (saldrás en el vídeo 😎)
Buenas,
Tal y como puse en lo comentarios, comparto aquí mi versión (cuidado que latitud y longitud están como XXXXXX)
Llegada la hora de la oscuridad se enciende una luz y pasadas las 23h, si el móvil de mi mujer y el mío están cargando (siempre lo ponemos a cargar cuando nos metemos en la cama), se apaga todo.
[ { "id": "8bbe171c.b08828", "type": "tab", "label": "Encender cuando anochezca", "disabled": false, "info": "" }, { "id": "c537c1b5.7515b", "type": "bigtimer", "z": "8bbe171c.b08828", "outtopic": "", "outpayload1": "", "outpayload2": "", "name": "De oscuridad a 23:00", "comment": "", "lat": "xxxxxx", "lon": XXXXX", "starttime": 5001, "endtime": "1380", "starttime2": 0, "endtime2": 0, "startoff": "-10", "endoff": "0", "startoff2": 0, "endoff2": 0, "offs": 0, "outtext1": "", "outtext2": "", "timeout": 1440, "sun": true, "mon": true, "tue": true, "wed": true, "thu": true, "fri": true, "sat": true, "jan": true, "feb": true, "mar": true, "apr": true, "may": true, "jun": true, "jul": true, "aug": true, "sep": true, "oct": true, "nov": true, "dec": true, "day1": 0, "month1": 0, "day2": 0, "month2": 0, "day3": 0, "month3": 0, "day4": 0, "month4": 0, "day5": 0, "month5": 0, "day6": 0, "month6": 0, "day7": 0, "month7": 0, "day8": 0, "month8": 0, "day9": 0, "month9": 0, "day10": 0, "month10": 0, "day11": 0, "month11": 0, "day12": 0, "month12": 0, "d1": 0, "w1": 0, "d2": 0, "w2": 0, "d3": 0, "w3": 0, "d4": 0, "w4": 0, "d5": 0, "w5": 0, "d6": 0, "w6": 0, "xday1": 0, "xmonth1": 0, "xday2": 0, "xmonth2": 0, "xday3": 0, "xmonth3": 0, "xday4": 0, "xmonth4": 0, "xday5": 0, "xmonth5": 0, "xday6": 0, "xmonth6": 0, "xd1": 0, "xw1": 0, "xd2": 0, "xw2": 0, "xd3": 0, "xw3": 0, "xd4": 0, "xw4": 0, "xd5": 0, "xw5": 0, "xd6": 0, "xw6": 0, "suspend": false, "random": false, "randon1": false, "randoff1": false, "randon2": false, "randoff2": false, "repeat": true, "atstart": true, "odd": false, "even": false, "x": 420, "y": 280, "wires": [ [], [ "6539f372.ce38ec" ], [] ] }, { "id": "6539f372.ce38ec", "type": "switch", "z": "8bbe171c.b08828", "name": "⬆OFF/ ⬇ON", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "0", "vt": "num" }, { "t": "eq", "v": "1", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 640, "y": 280, "wires": [ [ "8ab792fc.d8593" ], [ "d4296837.1b3d58", "6d3e8aaa.74a684", "b1428fc2.b7a3d" ] ] }, { "id": "d4296837.1b3d58", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Encender", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "light", "service": "turn_on", "entityId": "light.lamparita", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1140, "y": 360, "wires": [ [] ] }, { "id": "60bb7f20.6a5b5", "type": "inject", "z": "8bbe171c.b08828", "name": "Forzar en rango", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 100, "y": 100, "wires": [ [ "c537c1b5.7515b" ] ] }, { "id": "45fb30ec.33ce3", "type": "inject", "z": "8bbe171c.b08828", "name": "Forzar fuera de rango", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "0", "payloadType": "num", "x": 120, "y": 140, "wires": [ [ "c537c1b5.7515b" ] ] }, { "id": "7e4c61b5.c241", "type": "comment", "z": "8bbe171c.b08828", "name": "Fuera de rango", "info": "Cambia el Entity ID por el identificador de tu entidad", "x": 640, "y": 220, "wires": [] }, { "id": "d7b854c0.0c2d98", "type": "comment", "z": "8bbe171c.b08828", "name": "Dentro de rango", "info": "Cambia el Entity ID por el identificador de tu entidad", "x": 640, "y": 340, "wires": [] }, { "id": "6d3e8aaa.74a684", "type": "api-current-state", "z": "8bbe171c.b08828", "name": "¿Encendida demas del salon?", "server": "90696abf.b46218", "version": 1, "outputs": 2, "halt_if": "on", "halt_if_type": "str", "halt_if_compare": "is", "override_topic": false, "entity_id": "light.salon", "state_type": "str", "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "blockInputOverrides": false, "x": 910, "y": 420, "wires": [ [ "4903a077.7f078" ], [] ] }, { "id": "4903a077.7f078", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Apagar", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "light", "service": "turn_off", "entityId": "light.salon", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1140, "y": 420, "wires": [ [] ] }, { "id": "b1428fc2.b7a3d", "type": "api-current-state", "z": "8bbe171c.b08828", "name": "¿Encendida demas del salon?", "server": "90696abf.b46218", "version": 1, "outputs": 2, "halt_if": "on", "halt_if_type": "str", "halt_if_compare": "is", "override_topic": false, "entity_id": "light.salon_ventana", "state_type": "str", "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "blockInputOverrides": false, "x": 910, "y": 480, "wires": [ [ "b1096cc3.93e87" ], [] ] }, { "id": "b1096cc3.93e87", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Apagar", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "light", "service": "turn_off", "entityId": "light.salon_ventana", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1140, "y": 480, "wires": [ [] ] }, { "id": "8fb07831.b543f8", "type": "api-current-state", "z": "8bbe171c.b08828", "name": "¿Cargando Iphone2?", "server": "90696abf.b46218", "version": 1, "outputs": 2, "halt_if": "Charging", "halt_if_type": "str", "halt_if_compare": "is", "override_topic": false, "entity_id": "sensor.iphone_de_emilio_battery_state_2", "state_type": "str", "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "blockInputOverrides": false, "x": 1100, "y": 220, "wires": [ [ "c966442b.00c348", "268aba93.2e5996", "9198e799.22b7c8" ], [] ] }, { "id": "c966442b.00c348", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Apagar", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "light", "service": "turn_off", "entityId": "light.lamparita, automation.interruptor_salon_ventana, light.salon, light.cocina", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1300, "y": 140, "wires": [ [] ] }, { "id": "268aba93.2e5996", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Apagar", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "media_player", "service": "turn_off", "entityId": "media_player.tele", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1300, "y": 200, "wires": [ [] ] }, { "id": "9198e799.22b7c8", "type": "api-call-service", "z": "8bbe171c.b08828", "name": "Apagar", "server": "90696abf.b46218", "version": 1, "debugenabled": false, "service_domain": "switch", "service": "turn_off", "entityId": "switch.enchufe_sofa", "data": "", "dataType": "json", "mergecontext": "", "output_location": "", "output_location_type": "none", "mustacheAltTags": false, "x": 1300, "y": 260, "wires": [ [] ] }, { "id": "4f3943ce.876a0c", "type": "server-state-changed", "z": "8bbe171c.b08828", "name": "IB", "server": "90696abf.b46218", "version": 1, "exposeToHomeAssistant": false, "haConfig": [ { "property": "name", "value": "" }, { "property": "icon", "value": "" } ], "entityidfilter": "input_boolean.desactivar_luces_automaticas", "entityidfiltertype": "exact", "outputinitially": false, "state_type": "str", "haltifstate": "on", "halt_if_type": "str", "halt_if_compare": "is", "outputs": 2, "output_only_on_state_change": true, "for": 0, "forType": "num", "forUnits": "minutes", "ignorePrevStateNull": false, "ignorePrevStateUnknown": false, "ignorePrevStateUnavailable": false, "ignoreCurrentStateUnknown": false, "ignoreCurrentStateUnavailable": false, "x": 50, "y": 280, "wires": [ [ "7e98d977.ffea98" ], [ "8a1eb9b8.084d08" ] ] }, { "id": "8a1eb9b8.084d08", "type": "change", "z": "8bbe171c.b08828", "name": "Parar", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "stop", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 210, "y": 320, "wires": [ [ "c537c1b5.7515b" ] ] }, { "id": "7e98d977.ffea98", "type": "change", "z": "8bbe171c.b08828", "name": "Auto", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "auto", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 210, "y": 240, "wires": [ [ "c537c1b5.7515b" ] ] }, { "id": "8ab792fc.d8593", "type": "api-current-state", "z": "8bbe171c.b08828", "name": "¿Cargando iphone 1?", "server": "90696abf.b46218", "version": 1, "outputs": 2, "halt_if": "Charging", "halt_if_type": "str", "halt_if_compare": "is", "override_topic": false, "entity_id": "sensor.iphone_de_esperanza_battery_state", "state_type": "str", "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "blockInputOverrides": false, "x": 880, "y": 220, "wires": [ [ "8fb07831.b543f8" ], [] ] }, { "id": "90696abf.b46218", "type": "server", "name": "Home Assistant", "addon": true } ]
Código de la automatización
Explicación de lo que hace actualmente la automatización Estas automatizaciones lo que hacen es lo siguiente:
Notas del autor Podría agregarse que si alguien la enciende después de las 11, se apague 30 minutos después si la dejan encendida.