mampfes / ha_epex_spot

Adds EPEX Spot data to Home Assistant.
MIT License
130 stars 19 forks source link

template #106

Closed clarenze666 closed 6 months ago

clarenze666 commented 7 months ago

I was trying to modify the proposed template so that it will also activate the heating when no epex data is available. I tried the following:

    sensor:
      - name: "EPEX Start 24h Low Period"
        device_class: timestamp
        state: "{{ resp.start if resp.start is defined else (today_at("03:00") + timedelta(days=1)) }}"

But home-assistant does not buy it. The error message does not help. What did I make wrong? I can't figure it out.

clarenze666 commented 6 months ago

I was trying to modify the proposed template so that it will also activate the heating when no epex data is available. I tried the following:

    sensor:
      - name: "EPEX Start 24h Low Period"
        device_class: timestamp
        state: "{{ resp.start if resp.start is defined else (today_at("03:00") + timedelta(days=1)) }}"

But home-assistant does not buy it. The error message does not help. What did I make wrong? I can't figure it out.

I finally figured it out: I have to use single quotes.

    sensor:
      - name: "EPEX Start 24h Low Period"
        device_class: timestamp
        state: "{{ resp.start if resp.start is defined else (today_at('03:00') + timedelta(days=1)) }}"

Any ideas how I can test it? I.e. how can I simulate that epex does not get any data?

mampfes commented 6 months ago

You can temporary maniplate the code, e.g. invert the logic in this line: https://github.com/mampfes/ha_epex_spot/blob/77e6fd1692fb6a4ff0716f9356447aeb3eca71b4/custom_components/epex_spot/__init__.py#L152