Repository navigation
Publish the tariff 1/2 energy counters in the Home Assistant format - #1337
Merged
Merged
Conversation
The JSON and Raw MQTT formats already carry 1.8.1/1.8.2 and 2.8.1/2.8.2, but the Home Assistant /energy payload only had the totals, so meters that report per-tariff registers showed them in the web UI and not in HA. Add tPIT1/tPIT2/tPOT1/tPOT2 (same keys as the JSON format) to the energy payload, with discovery sensors that are announced only once a tariff register is non-zero, so meters without them get no sensors stuck at 0. Refs #1333 Co-Authored-By: Claude Opus 5.5 <[email protected]>
🔧 PR Build ArtifactsVersion: All environments built successfully. Download the zip files:
|
|
I have tested this PR build artifact on my esp32c3 and it works, now i get Tariff counters in HomeAssistant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#1333: on an Iskra IE.5 (Croatia), the web UI shows the tariff 1/2 energy counters (1.8.1/1.8.2, 2.8.1/2.8.2, decoded for that meter since #1321), but Home Assistant doesn't get them.
The JSON format already publishes them as
tPIT1/tPIT2/tPOT1/tPOT2, and the Raw format publishes them under…/accumulated/tariff1|2. The Home Assistant format's/energypayload (ha2.json) only hadtPI/tPO/tQI/tQO, and no discovery sensors existed for the tariff registers.Changes
ha2.json/publishList3(): addtPIT1,tPIT2,tPOT1,tPOT2to the/energypayload, using the same keys as the JSON format.HomeAssistantStatic.h: add four discovery sensors ("Accumulated active import/export tariff 1/2", kWh,energy,total_increasing). The import pair is announced once either import tariff register is non-zero, and the export pair once either export register is non-zero. This follows the pattern of the existing export sensors, so meters without tariff registers don't get sensors stuck at 0.onlineand on config change.The "choose which values to publish" part of the issue is not included.
Verification
pio run -e esp8266andpio run -e esp32build.ha2.jsonon the host with the 8 counters and 2 timestamps in the same order as thesnprintf_Parguments, and checked that the result parses as JSON with the expected keys.Refs #1333
🤖 Generated with Claude Code