amsreader-firmware icon indicating copy to clipboard operation
amsreader-firmware copied to clipboard

Priser via MQTT (Home Assistant auto discovery)

Open Handl3vogn opened this issue 2 years ago • 7 comments

Hei Ser ikke ut som jeg får noen priser over mqtt (Home Assistant auto discovery). Har satt opp ENTSO-E API og får priser i web grensesnittet men får dem ikke over til home-assistant.

Hardware information:

  • Meter: [Kamstrup]
  • AMS reader: [Pow-K, ESP32] Skjermbilde fra 2022-04-04 16-38-55 Skjermbilde fra 2022-04-04 16-44-19

Handl3vogn avatar Apr 04 '22 14:04 Handl3vogn

For anyone else visiting this issue, I can confirm that HA autodiscovery for prices have not been implemented. As I do not have a HA setup and do not have time to dive in to this, feel free to provide a working solution. If you do not have coding experience, auto discovery JSON for each necessary sensor is sufficient.

gskjold avatar Apr 05 '22 06:04 gskjold

Energy prices in Home Assistant can be retrieved using the Nordpool component:

https://github.com/custom-components/nordpool

PalmMx avatar Apr 05 '22 12:04 PalmMx

As I understand it, Nordpool have deprecated their API, and there's a good chance it'll be discontinued or break entirely, soon.

On-topic: Is the price still sent when in Home Assistant mode (but just not auto discovered), or would I have to switch to JSON mode?

DarkFox avatar Jun 27 '22 23:06 DarkFox

Looks like I was on an older version, and that's why the prices weren't showing up.

However, the Home Assistant feed, seems to be missing a number of things.

  • It only includes the next 12 hours of prices (out of 22 hrs total, at the time I tested).
  • No real time price calculations.
  • The messages don't seem to be retained (Not sure if that's just the prices, or all of them).
Besked 327 er modtaget på kamstrup/prices kl. 01.38:

{
    "id": "58:CF:79:9F:B6:24",
    "prices": {
        "0": 1.962,
        "1": 1.9201,
        "2": 1.9057,
        "3": 1.8939,
        "4": 2.0005,
        "5": 2.462,
        "6": 2.6632,
        "7": 2.7608,
        "8": 2.592,
        "9": 2.4742,
        "10": 2.1837,
        "11": 1.994,
        "min": 1.8668,
        "max": 3.2997,
        "cheapest1hr": "2022-06-28T11:00:00Z",
        "cheapest3hr": "2022-06-28T11:00:00Z",
        "cheapest6hr": "2022-06-28T09:00:00Z"
    }
}

DarkFox avatar Jun 27 '22 23:06 DarkFox

Will look into getting more information in HA mode. The price JSON was limited to 12 hrs because of memory constraints with ESP8266, but it could be that it can be expanded now with the larger buffer. Raw mode has all available hours in separate topics.

gskjold avatar Jun 28 '22 08:06 gskjold

I'm slightly confused, why you wouldn't just use an array for the values? That would save quite a lot of characters and make it easier to use in most applications. Like so: "future_prices": [1.962, 1.9201, 1.9057, 1.8939, 2.0005, 2.462, 2.6632, 2.7608, ....],

DarkFox avatar Jun 28 '22 11:06 DarkFox

Sounds reasonable. If this checks out to be true for both Home Assistant and OpenHAB, it probably holds true for other systems as well, and I can make that change

gskjold avatar Jun 28 '22 12:06 gskjold

Work in progress. Currently implemented auto configuration for sensors containing price and realtime data.

What I need to verify:

  • The new firmware functions with device configured from old auto config data (Version 2.1.7 or below)
  • The new price sensors are functioning as expected (Has future price 0-11, min/max price ahead and 1hr, 3hr and 6hr cheapest times ahead)
  • Real time sensors functioning as expected (Has month max, threshold, peaks, hour/day/month use/cost/produced)

WARNING: Use the DEV firmware below at your own risk. You need to be able to flash by USB/TTL if firmware does not work. esp32.zip esp32s2.zip esp8266.zip

gskjold avatar Sep 28 '22 18:09 gskjold

Installed HA on VirtualBox for testing, made some adjustments: esp8266.zip esp32s2.zip esp32.zip

gskjold avatar Sep 30 '22 17:09 gskjold

Merged this issue into #320

gskjold avatar Sep 30 '22 17:09 gskjold

Looks great! I'll test it later this week. Are you planning of exposing all 22 hrs prices? Either as a list or only enable for esp32?

kklem0 avatar Oct 03 '22 10:10 kklem0

Will expose all hours in a future release

gskjold avatar Oct 06 '22 09:10 gskjold