Hello,
i progress a little Not alone with help of ChatGPT but don't replace help of all of you expert.
But don't know if i use correctly the state and use to much ressource. May be there are nodes which don't be reason for existing.
No i must find a way if the light is not "ON", it switch on this one at the correct temp color.
[
{
"id": "8d595d2b5ddfea11",
"type": "tab",
"label": "TestTemperature",
"disabled": false,
"info": "",
"env": []
},
{
"id": "33f7254cd40140ee",
"type": "inject",
"z": "8d595d2b5ddfea11",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "dial_rotate_right_step",
"payloadType": "str",
"x": 280,
"y": 460,
"wires": [
[
"f7fb988ebf4c67e3"
]
]
},
{
"id": "f7fb988ebf4c67e3",
"type": "switch",
"z": "8d595d2b5ddfea11",
"name": "Switch on Dial Rotate Right",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "dial_rotate_right_step",
"vt": "str"
},
{
"t": "eq",
"v": "dial_rotate_right_slow",
"vt": "str"
},
{
"t": "eq",
"v": "dial_rotate_right_fast",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 570,
"y": 540,
"wires": [
[
"493c92ddcccf8207"
],
[
"493c92ddcccf8207"
],
[
"493c92ddcccf8207"
]
]
},
{
"id": "95235b012bad7d34",
"type": "switch",
"z": "8d595d2b5ddfea11",
"name": "Switch on Dial Rotate Left",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "dial_rotate_left_step",
"vt": "str"
},
{
"t": "eq",
"v": "dial_rotate_left_slow",
"vt": "str"
},
{
"t": "eq",
"v": "dial_rotate_left_fast",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 550,
"y": 620,
"wires": [
[
"64b398cce0301e19"
],
[
"64b398cce0301e19"
],
[
"64b398cce0301e19"
]
]
},
{
"id": "f9e473071b383bf0",
"type": "inject",
"z": "8d595d2b5ddfea11",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "dial_rotate_left_step",
"payloadType": "str",
"x": 270,
"y": 740,
"wires": [
[
"95235b012bad7d34"
]
]
},
{
"id": "3353c06cab4d553b",
"type": "api-call-service",
"z": "8d595d2b5ddfea11",
"name": "Light UP",
"server": "92ab386eaaffa3ef",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.zig"
],
"data": "payload",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1220,
"y": 420,
"wires": [
[
"8f2317f90cb7781a"
]
]
},
{
"id": "7436f915208cbde6",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "WarmColor",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1590,
"y": 440,
"wires": []
},
{
"id": "fdc460fab1aa2204",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "Coldcolor",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1440,
"y": 720,
"wires": []
},
{
"id": "e5179f6abd6ab5ec",
"type": "function",
"z": "8d595d2b5ddfea11",
"name": "GoToWarm",
"func": "// Récupérer la valeur actuelle de \"color_temp\" depuis le contexte\n//var currentColorTemp = context.get('currentColorTemp') || 154;\nvar currentColorTemp = flow.get('Temp') || 154;\n// Ajouter 10 à la valeur actuelle de \"color_temp\"\nvar newColorTemp = currentColorTemp + 32;\n\n// Limiter la nouvelle valeur de \"color_temp\" à 500\nnewColorTemp = Math.min(newColorTemp, 500);\n\n// Mettre à jour la valeur de \"color_temp\" dans le contexte\ncontext.set('currentColorTemp', newColorTemp);\n\n// Mettre à jour le payload avec la nouvelle valeur de \"color_temp\"\nmsg.payload = {\n \"color_temp\": newColorTemp\n};\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1030,
"y": 440,
"wires": [
[
"3353c06cab4d553b",
"41e22f30acd99c1a"
]
]
},
{
"id": "247a82eee85cefcb",
"type": "inject",
"z": "8d595d2b5ddfea11",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 730,
"y": 440,
"wires": [
[
"e5179f6abd6ab5ec"
]
]
},
{
"id": "3690ccfbbb7c0d84",
"type": "inject",
"z": "8d595d2b5ddfea11",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 970,
"y": 800,
"wires": [
[
"586f4cbd8a2e4a58"
]
]
},
{
"id": "41e22f30acd99c1a",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "debug 72",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1280,
"y": 540,
"wires": []
},
{
"id": "68561378b6fe68ed",
"type": "mqtt in",
"z": "8d595d2b5ddfea11",
"name": "",
"topic": "zigbee2mqtt/HueSwitch/action",
"qos": "2",
"datatype": "auto-detect",
"broker": "99709302a818dd3b",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 220,
"y": 580,
"wires": [
[
"f7fb988ebf4c67e3",
"95235b012bad7d34"
]
]
},
{
"id": "493c92ddcccf8207",
"type": "api-current-state",
"z": "8d595d2b5ddfea11",
"name": "",
"server": "92ab386eaaffa3ef",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "light.zig",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 840,
"y": 540,
"wires": [
[
"e5179f6abd6ab5ec"
]
]
},
{
"id": "8f2317f90cb7781a",
"type": "api-current-state",
"z": "8d595d2b5ddfea11",
"name": "",
"server": "92ab386eaaffa3ef",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "light.zig",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 1420,
"y": 320,
"wires": [
[
"7436f915208cbde6"
]
]
},
{
"id": "fbfec0d1669d9a0b",
"type": "api-current-state",
"z": "8d595d2b5ddfea11",
"name": "",
"server": "92ab386eaaffa3ef",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "light.zig",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 1300,
"y": 620,
"wires": [
[
"fdc460fab1aa2204"
]
]
},
{
"id": "586f4cbd8a2e4a58",
"type": "function",
"z": "8d595d2b5ddfea11",
"name": "GoToCold",
"func": "// Récupérer la valeur actuelle de \"color_temp\" depuis le contexte\nvar currentColorTemp = flow.get('Temp') || 500;\n\n// Soustrait 10 à la valeur actuelle de \"color_temp\"\nvar newColorTemp = currentColorTemp - 32;\n\n// Limiter la nouvelle valeur de \"color_temp\" à 154\nnewColorTemp = Math.max(newColorTemp, 154);\n\n// Mettre à jour la valeur de \"color_temp\" dans le contexte\ncontext.set('currentColorTemp', newColorTemp);\n\n// Mettre à jour le payload avec la nouvelle valeur de \"color_temp\"\nmsg.payload = {\n \"color_temp\": newColorTemp\n};\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1040,
"y": 720,
"wires": [
[
"7093f6a761b273c5"
]
]
},
{
"id": "57284b3dd2a6b7aa",
"type": "api-call-service",
"z": "8d595d2b5ddfea11",
"name": "Light Down",
"server": "92ab386eaaffa3ef",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.zig"
],
"data": "{\t \"color_temp\": 153}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1210,
"y": 820,
"wires": [
[]
]
},
{
"id": "7093f6a761b273c5",
"type": "api-call-service",
"z": "8d595d2b5ddfea11",
"name": "Light DOWN",
"server": "92ab386eaaffa3ef",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.zig"
],
"data": "payload",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1210,
"y": 740,
"wires": [
[
"fbfec0d1669d9a0b"
]
]
},
{
"id": "64b398cce0301e19",
"type": "api-current-state",
"z": "8d595d2b5ddfea11",
"name": "",
"server": "92ab386eaaffa3ef",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "light.zig",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 820,
"y": 680,
"wires": [
[
"586f4cbd8a2e4a58"
]
]
},
{
"id": "61815ce19ba3d2d5",
"type": "server-state-changed",
"z": "8d595d2b5ddfea11",
"name": "",
"server": "92ab386eaaffa3ef",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": "light.zig",
"entityIdType": "exact",
"outputInitially": true,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": false,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "media",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
}
],
"x": 280,
"y": 80,
"wires": [
[
"cf754db00946cbc5",
"41f6bea9fca80071",
"c4ad8bc0a6d228ec"
]
]
},
{
"id": "41f6bea9fca80071",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "media.new_state.attributes.color_temp",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 100,
"wires": []
},
{
"id": "cf754db00946cbc5",
"type": "change",
"z": "8d595d2b5ddfea11",
"name": "save Brightness and Temperature",
"rules": [
{
"t": "set",
"p": "Temp",
"pt": "flow",
"to": "media.new_state.attributes.color_temp",
"tot": "msg"
},
{
"t": "set",
"p": "Bright",
"pt": "flow",
"to": "media.new_state.attributes.brightness",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 160,
"wires": [
[
"b98b770842e756f5"
]
]
},
{
"id": "c4ad8bc0a6d228ec",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "media.new_state.attributes.brightness",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 40,
"wires": []
},
{
"id": "b98b770842e756f5",
"type": "debug",
"z": "8d595d2b5ddfea11",
"name": "debug 73",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1010,
"y": 160,
"wires": []
},
{
"id": "ad43504401a2b40c",
"type": "api-call-service",
"z": "8d595d2b5ddfea11",
"name": "Light Up",
"server": "92ab386eaaffa3ef",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.zig"
],
"data": "{\t \"color_temp\": 500}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1200,
"y": 280,
"wires": [
[]
]
},
{
"id": "92ab386eaaffa3ef",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
},
{
"id": "99709302a818dd3b",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.1.77",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]