Super Jean-Marc
Oui, je fais bien référence à l’issue 398 (j’aurais peut dû commenter sur l’issue, désolé).
Concernant ma solution:
-
Créer une entrée de type nombre
-
configuration.yaml
# Sonde Bureau - fake sensor
- platform: template
sensors:
SondeBureauFakeTemperature:
friendly_name: 'Sonde Bureau fake Temperature '
value_template: >
{{ states('Sonde Bureau Fake Temperature', rounded=True) }}
unit_of_measurement: '°C'
icon_template: mdi:temperature-celsius
- Scénario Nodered
[{"id":"cb2c8ed3f7d56ae6","type":"inject","z":"bff36163dcac8dfc","name":"Toutes les 5mn","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":false,"onceDelay":0.1,"topic":"Each5mn","payload":"","payloadType":"date","x":160,"y":140,"wires":[["1159dbd7933abae6"]]},{"id":"1159dbd7933abae6","type":"function","z":"bff36163dcac8dfc","name":"Gestion Température Sonde Bureau","func":"const globalHomeAssistant = global.get('homeassistant');\ncontext.data = context.data || {};\nvar msg1; //temp fake sensor\nvar msg2; //tempo déclenchée sur fake temp envoyée, avant retour à temp réelle\n\nvar SondeBureauTemp = Number(globalHomeAssistant.homeAssistant.states[\"sensor.0x3410f4fffede5531_temperature\"].state);\nvar SondeBureauFakeTemp = Number(globalHomeAssistant.homeAssistant.states[\"input_number.sonde_bureau_fake_temperature\"].state);\nvar Maintenant0 = new Date(globalHomeAssistant.homeAssistant.states['sensor.date_time_iso'].state);\nvar Maintenant1 = Maintenant0.getTime();\nvar VThermSecurity = globalHomeAssistant.homeAssistant.states[\"binary_sensor.radiateur_atlantic_security_state\"].state;\n//Last Temp Date utilisée par Versatile Thermometer\nvar VThermLastTempDate = new Date(globalHomeAssistant.homeAssistant.states['sensor.radiateur_atlantic_last_temperature_date'].state);\nvar VThermLastTempDiff = Maintenant1 - VThermLastTempDate.getTime();\n// timestamp et timediff en ms\nvar SondeBureauLastSeen = new Date(globalHomeAssistant.homeAssistant.states[\"sensor.sonde_bureau_sonoff_last_seen\"].state);\nvar LastSeenTimeDiff = Maintenant1 - SondeBureauLastSeen.getTime();\n\nswitch (msg.topic) {\n case \"Each5mn\":\n // si La temp de la sonde bureau a été rafraîchie il y a moins de 10mn, c'est que la sonde est active\n if (LastSeenTimeDiff < 600000) {\n //la sonde fake prend la valeur de la sonde bureau\n msg1 = { payload: SondeBureauTemp };\n };\n break;\n case \"VThermSecurity\":\n // si Versatile Thermostat a déclenché la mise en Sécurité\n if (VThermSecurity == 'on') {\n // si La temp de la sonde bureau a été rafraîchie il y a moins de 10mn, c'est que la sonde est active\n if (LastSeenTimeDiff < 600000) {\n //la sonde fake prend la valeur de la sonde bureau + 0.5°C pour réactiver VTherm\n msg1 = { payload: SondeBureauTemp + 0.5 };\n }\n } else {\n // la mise en sécurité a été annulée, retour à la normale, la sonde fake prend la valeur de la sonde bureau\n msg1 = { payload: SondeBureauTemp };\n };\n break;\n default:\n};\n\n// debug\nnode.warn({ \n \"SondeBureauTemp\": SondeBureauTemp,\n \"SondeBureauFakeTemp\": SondeBureauFakeTemp, \n \"VThermSecurity\": VThermSecurity,\n \"Maintenant\": Maintenant0,\n \"SondeBureauLastSeen\": SondeBureauLastSeen,\n \"LastSeenTimeDiff (sec)\": LastSeenTimeDiff/1000,\n \"VThermLastTempDate\": VThermLastTempDate,\n \"VThermLastTempDiff (mn)\": parseFloat((VThermLastTempDiff/60000).toFixed(0)),\n});\n\nreturn[msg1];","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":140,"wires":[["d75bd0fadb3a2cee","95b4dd15c736cd56"]]},{"id":"88531fac65436087","type":"api-current-state","z":"bff36163dcac8dfc","name":"VTherm Security","server":"c879ac61.99cd1","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.radiateur_atlantic_security_state","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"VThermSecurity","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":150,"y":200,"wires":[["1159dbd7933abae6"]]},{"id":"d75bd0fadb3a2cee","type":"debug","z":"bff36163dcac8dfc","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":80,"wires":[]},{"id":"95b4dd15c736cd56","type":"api-call-service","z":"bff36163dcac8dfc","name":"Sonde Bureau Fake Temperature","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"input_number","service":"set_value","areaId":[],"deviceId":[],"entityId":["input_number.sonde_bureau_fake_temperature"],"data":"{ \"value\": payload }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":140,"wires":[[]]},{"id":"eae7acaf032b3577","type":"comment","z":"bff36163dcac8dfc","name":"Gestion Sécurité VTherm Radiateur Bureau","info":"","x":230,"y":60,"wires":[]},{"id":"254518a8a6fecb9d","type":"inject","z":"bff36163dcac8dfc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":280,"wires":[["88531fac65436087"]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]