Tibber günstigste Stunden - Template Sensor - geht das auch über eine Automation?

Hallo Allerseits,

ich habe in HA 10 binaray sensoren von binary_sensor.tibber_cheap_hr_1 bis binary_sensor.tibber_cheap_hr_10.

Die sind zur möglichen Steuerung von Verbrauchern wie folgt “true” - Beispiel:

  1. binary_sensor.tibber_cheap_hr_1 - Nur einmal/24 Std. während der günstigsten Stunde

  2. binary_sensor.tibber_cheap_hr_10 - entsperchend “true” während der 10 günstigsten Stunden.

Ich benutze die verschiedenen Sensoren u.a. zur Steuerung von 2 smarten Nachtspeicheröfen zur Aufladung derer.

Im Ulanzi Display habe ich dann auch folgende Anzeige, z.b. sofern Sensor 10 auf true steht. Den aktuellen Tibber Bruttopreis/Cent|10 - sieht dann so aus:

Also aktuell 30 Cent und eine der 10 günstigsten Stunden…

Sofern aktuell keine der günstigsten Stunden, wird ein * ausgegeben:

Der Code als Template Sensor dazu:

- sensor:
    - name: "Tibber günstigste Stunde"
      unique_id: "TibberGuensigsteStunde"
      state: >
          {% set electricity_price = states('sensor.electricity_price_muhlenstrasse_1a') | multiply(100) | round(0) %}
          {% set sensors = ['binary_sensor.tibber_cheap_hr_1', 'binary_sensor.tibber_cheap_hr_2', 'binary_sensor.tibber_cheap_hr_3', 'binary_sensor.tibber_cheap_hr_4', 'binary_sensor.tibber_cheap_hr_5', 'binary_sensor.tibber_cheap_hr_6', 'binary_sensor.tibber_cheap_hr_7', 'binary_sensor.tibber_cheap_hr_8', 'binary_sensor.tibber_cheap_hr_9', 'binary_sensor.tibber_cheap_hr_10'] %}
          {{ electricity_price }}|{%
              if is_state(sensors[0], 'on') %}1{%
              elif is_state(sensors[1], 'on') %}2{%
              elif is_state(sensors[2], 'on') %}3{%
              elif is_state(sensors[3], 'on') %}4{%
              elif is_state(sensors[4], 'on') %}5{%
              elif is_state(sensors[5], 'on') %}6{%
              elif is_state(sensors[6], 'on') %}7{%
              elif is_state(sensors[7], 'on') %}8{%
              elif is_state(sensors[8], 'on') %}9{%
              elif is_state(sensors[9], 'on') %}10{%
              else %}*{%
              endif %}
      attributes:
          minute_counter: "{{ now().minute }}"

Mein Fragen:

  1. Habe dazu noch keine Lösung gefunden, ließe sich das auch anstatt Template Sensor über eine Automation realisieren - ggf. sofern nicht

  2. Mein Template Sensor Code ist recht lang/komplex. Ginge das auch kürzer? Mit Schleifen/anderen Variabeln nach ChatGPT Vorschlägen hatte ich das zumindest nicht hinbekommen.

VG

2 „Gefällt mir“

Die Neuberechnung bräuchte man nur einmal pro Tag um 13h00 (bzw. kurz dannach) wenn die neuen Preise kommen, oder?
Wo kommt Dein binary_sensor.tibber_cheap_hr_1 her?

Ist ein NodeRed Flow, den ich schon unterm IoBroker in Verwendung hatte.
Ja, die neuen Preise kommen immer um 13:00 Uhr. Ich trigger den Flow allerdings stündlich vorne über den Timestamp Node, damit sich hinten raus die HA Entitäten cheap hr 1 bis 10 auch entsprechend stündlich aktualisieren.

Im Node “Tibber Query” gehört dann der eigene Tibber Token rein.
Der Flow zum möglichen Import:

[{"id":"86d000b579debf61","type":"tab","label":"Tibber Günstigste Stunden","disabled":false,"info":"","env":[]},{"id":"1431605b2d20555b","type":"inject","z":"86d000b579debf61","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"0 0-23 * * *","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":260,"wires":[["99594a21f61dcf53"]]},{"id":"99594a21f61dcf53","type":"template","z":"86d000b579debf61","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  viewer {\n    homes {\n      currentSubscription {\n        priceInfo {\n          today {\n            total\n            startsAt\n          }\n          tomorrow {\n            total\n            startsAt\n          }\n        }\n      }\n    }\n  }\n}","output":"str","x":340,"y":260,"wires":[["3a406cd74a465339"]]},{"id":"3a406cd74a465339","type":"tibber-query","z":"86d000b579debf61","name":"Tibber Query","active":true,"apiEndpointRef":"6c0ebed9c4db1a3b","x":510,"y":260,"wires":[["eb1644a5e8baecb8"]]},{"id":"eb1644a5e8baecb8","type":"ps-receive-price","z":"86d000b579debf61","name":"Price Receiver","x":700,"y":260,"wires":[["7659982adc0e294f","8aa67fc363a3a2ee","c375988822ca6220","733acc158526de21","b90704fe78cf2b38","47a7434b094a9f39","a2da6bca9e5fc44f","4296c3a8732d8cab","56211fc8b5aff163","346d1ea3bcd76627"]]},{"id":"7659982adc0e294f","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 2hrs","fromTime":"00","toTime":"00","hoursOn":"2","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":320,"wires":[["b45855afd1ca7bb8"],["b45855afd1ca7bb8"],[]]},{"id":"8aa67fc363a3a2ee","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 3hrs","fromTime":"00","toTime":"00","hoursOn":"3","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":380,"wires":[["68e75fdccd1ca055"],["68e75fdccd1ca055"],[]]},{"id":"c375988822ca6220","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 4hrs","fromTime":"00","toTime":"00","hoursOn":"4","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":440,"wires":[["9b9a514ed40afc23"],["9b9a514ed40afc23"],[]]},{"id":"733acc158526de21","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 5hrs","fromTime":"00","toTime":"00","hoursOn":"5","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":500,"wires":[["bb3ef304d8f5b1bb"],["bb3ef304d8f5b1bb"],[]]},{"id":"b90704fe78cf2b38","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 6hrs","fromTime":"00","toTime":"00","hoursOn":"6","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":560,"wires":[["64537f499aee6861"],["64537f499aee6861"],[]]},{"id":"56211fc8b5aff163","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 7hrs","fromTime":"00","toTime":"00","hoursOn":"7","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":620,"wires":[["524724be7baa1c29"],["524724be7baa1c29"],[]]},{"id":"47a7434b094a9f39","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 8hrs","fromTime":"00","toTime":"00","hoursOn":"8","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":680,"wires":[["7c9c567ccd4e6a3b"],["7c9c567ccd4e6a3b"],[]]},{"id":"a2da6bca9e5fc44f","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 9hrs","fromTime":"00","toTime":"00","hoursOn":"9","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":740,"wires":[["9d2016523108cf8d"],["9d2016523108cf8d"],[]]},{"id":"4296c3a8732d8cab","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 10hrs","fromTime":"00","toTime":"00","hoursOn":"10","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":800,"wires":[["67c10c697c414735"],["67c10c697c414735"],[]]},{"id":"346d1ea3bcd76627","type":"ps-strategy-lowest-price","z":"86d000b579debf61","name":"Lowest Price 1hrs","fromTime":"00","toTime":"00","hoursOn":"1","maxPrice":"2","doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputValueForOn":"true","outputValueForOff":"false","outputValueForOntype":"bool","outputValueForOfftype":"bool","outputIfNoSchedule":"false","outputOutsidePeriod":"false","contextStorage":"memory","x":910,"y":260,"wires":[["7c63912725219c7b"],["7c63912725219c7b"],[]]},{"id":"7c63912725219c7b","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_1","entityConfig":"4e6f363bf4b0ab84","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":260,"wires":[[]]},{"id":"b45855afd1ca7bb8","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_2","entityConfig":"42ad2fa627f015cc","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":320,"wires":[[]]},{"id":"68e75fdccd1ca055","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_3","entityConfig":"852e3ee6c7aa2fc3","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":380,"wires":[[]]},{"id":"9b9a514ed40afc23","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_4","entityConfig":"df8558e9cbd0266c","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":440,"wires":[[]]},{"id":"bb3ef304d8f5b1bb","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_5","entityConfig":"8be1b394d30071ca","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":500,"wires":[[]]},{"id":"64537f499aee6861","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_6","entityConfig":"5e347836c27fbeda","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":560,"wires":[[]]},{"id":"524724be7baa1c29","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_7","entityConfig":"cd424ed5037f8ec4","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":620,"wires":[[]]},{"id":"7c9c567ccd4e6a3b","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_8","entityConfig":"b769858e0f0e83e1","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":680,"wires":[[]]},{"id":"9d2016523108cf8d","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_9","entityConfig":"d39c5623758097cb","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":740,"wires":[[]]},{"id":"67c10c697c414735","type":"ha-binary-sensor","z":"86d000b579debf61","name":"tibber_cheap_hr_10","entityConfig":"0caca1c4cb0bf593","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1250,"y":800,"wires":[[]]},{"id":"6c0ebed9c4db1a3b","type":"tibber-api-endpoint","queryUrl":"https://api.tibber.com/v1-beta/gql","feedConnectionTimeout":"30","feedTimeout":"60","queryRequestTimeout":"30","name":"Tibber Access Token"},{"id":"4e6f363bf4b0ab84","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_1","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_1"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":true,"debugEnabled":false},{"id":"42ad2fa627f015cc","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_2","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_2"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"852e3ee6c7aa2fc3","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_3","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_3"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"df8558e9cbd0266c","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_4","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_4"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"8be1b394d30071ca","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_5","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_5"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":true,"debugEnabled":false},{"id":"5e347836c27fbeda","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_6","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_6"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"cd424ed5037f8ec4","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_7","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_7"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"b769858e0f0e83e1","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_8","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_8"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"d39c5623758097cb","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_9","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_9"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"0caca1c4cb0bf593","type":"ha-entity-config","server":"208e54bc.173dec","deviceConfig":"","name":"tibber_cheap_hr_10","version":"6","entityType":"binary_sensor","haConfig":[{"property":"name","value":"tibber_cheap_hr_10"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false},{"id":"208e54bc.173dec","type":"server","name":"Home Assistant","addon":true}]

Benötigte Tibber Nodes in NodeRed zum Import:

1 „Gefällt mir“

Hey, welche Nodes hast du für price Receiver und Lowest Price benutzt? Bei mir sind diese Felder leider unbekannt.

VG

sollten die sein…:

perfekt, jetzt passt es… Danke.

@lemuba , hi, hast du die günstigen Stunden über die Template sensoren bestimmt oder arbeitest du jetzt mit Node red?
Mit Node Red habe ich mich noch nicht befasst.
image
timestamp kann ich im Node nicht finden