toreamun / amshan-homeassistant

Home Assistant integrasjon for strømmålere (AMS/HAN/P1). Integrasjonen støter både streaming (serieport/TCP-IP) og MQTT (Tibber Pulse, energyintelligence.se etc)
MIT License
146 stars 9 forks source link

Hourly usage is «off by one hour» compared to elhub.no #55

Closed bendiksolheim closed 1 year ago

bendiksolheim commented 1 year ago

Version of the custom_component

v2022.10.2

Configuration

(This is from «Download diagnostics» on the integration, I can provide other configs if needed)

Configuration ```json { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.12.8", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Europe/Oslo", "os_name": "Linux", "os_version": "5.15.76-v8", "supervisor": "2022.11.2", "host_os": "Home Assistant OS 9.4", "docker_version": "20.10.19", "chassis": "embedded", "run_as_root": true }, "custom_components": { "nordpool": { "version": "0.0.9", "requirements": [ "nordpool>=0.2" ] }, "pyscript": { "version": "1.3.3", "requirements": [ "croniter==1.3.4", "watchdog==2.1.6" ] }, "amshan": { "version": "2022.10.2", "requirements": [ "amshan[serial]==2.0.5" ] }, "ics_calendar": { "version": "3.1.6", "requirements": [ "ics>=0.7.2", "recurring_ical_events>=1.0.2b0", "icalendar>=4.1.0" ] }, "hacs": { "version": "1.29.0", "requirements": [ "aiogithubapi>=22.10.1" ] } }, "integration_manifest": { "domain": "amshan", "name": "AMS HAN meter", "version": "2022.10.2", "config_flow": true, "documentation": "https://github.com/toreamun/amshan-homeassistant", "issue_tracker": "https://github.com/toreamun/amshan-homeassistant/issues", "codeowners": [ "@toreamun" ], "requirements": [ "amshan[serial]==2.0.5" ], "after_dependencies": [ "mqtt" ], "iot_class": "local_push", "is_built_in": false }, "data": { "config_entry": { "entry_id": "54d49b908b692129f9bb84c37b7195d0", "version": 3, "domain": "amshan", "title": "Kaifa (mqtt)", "data": { "connection_type": "hass_mqtt", "connection": { "mqtt_topics": "pulse/publish" } }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "user", "unique_id": null, "disabled_by": null } } } ```

Describe the bug

It seems my hourly usage is off by one. Comparing my usage in HA Energy Dashboard towards elhub.no I consistently see hour N in HA is hour N-1 in elhub.no (e.g. hour 01.00-02.00 in HA is hour 00.00-01.00 in elhub.no). The actual values seems correct if I just shift everything one hour. I have attached screenshots from HA and elhub.no, and comparing the two graphs they are the same if we just skip the leftmost hour in HA.

If you give me any pointers on where to start and what to check, I’m happy to debug this myself (including code changes). I’m just not well versed enough in HA to know where to start looking and what could cause this.

Debug log

Debug log This is the debug log from a reboot when amshan starts to load, and a minute or so in. I can provide longer logs if needed, but what came after this seemed to mostly repeat the patterns captured here. ```text 2022-12-26 09:39:52.347 INFO (MainThread) [homeassistant.setup] Setting up amshan 2022-12-26 09:39:52.348 INFO (MainThread) [homeassistant.setup] Setup of domain amshan took 0.0 seconds 2022-12-26 09:39:52.390 DEBUG (MainThread) [custom_components.amshan.metercon] Try to subscribe to 1 MQTT topic(s): {'pulse/publish'} 2022-12-26 09:39:52.599 DEBUG (MainThread) [custom_components.amshan.metercon] Successfully subscribed to 1 MQTT topic(s): {'pulse/publish'} 2022-12-26 09:39:52.600 DEBUG (MainThread) [custom_components.amshan] Configured ConnectionType.MQTT receiver. 2022-12-26 09:39:52.608 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.amshan 2022-12-26 09:39:52.610 DEBUG (MainThread) [custom_components.amshan.sensor] Sensor async_setup_entry starting. 2022-12-26 09:39:52.610 DEBUG (MainThread) [custom_components.amshan.sensor] Sensor async_setup_entry ended. 2022-12-26 09:39:52.612 DEBUG (MainThread) [custom_components.amshan.sensor] Processing loop starting. 2022-12-26 09:39:52.613 DEBUG (MainThread) [custom_components.amshan] async_setup_entry complete. 2022-12-26 09:39:52.640 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 52.65s 2022-12-26 09:39:52.640 INFO (MainThread) [homeassistant.core] Starting Home Assistant 2022-12-26 09:39:52.658 INFO (MainThread) [custom_components.hacs] Stage changed: startup 2022-12-26 09:39:52.712 WARNING (MainThread) [homeassistant.components.netatmo] Webhook not registered - https and port 443 is required to register the webhook 2022-12-26 09:39:52.792 INFO (MainThread) [custom_components.hacs] Loading removed repositories 2022-12-26 09:39:52.838 INFO (MainThread) [homeassistant.components.automation.julelys_pa] Initialized trigger Julelys på 2022-12-26 09:39:52.838 INFO (MainThread) [homeassistant.components.automation.julelys_av] Initialized trigger Julelys av 2022-12-26 09:39:52.838 INFO (MainThread) [homeassistant.components.automation.vaskeromsdor_apnet] Initialized trigger Vaskeromsdør åpnet 2022-12-26 09:39:52.838 INFO (MainThread) [homeassistant.components.automation.vaskeromsdor_lukket] Initialized trigger Vaskeromsdør lukket 2022-12-26 09:39:52.839 INFO (MainThread) [homeassistant.components.automation.panelovn_soverom_pa] Initialized trigger Panelovn soverom på 2022-12-26 09:39:52.839 INFO (MainThread) [homeassistant.components.automation.panelovn_soverom_av] Initialized trigger Panelovn soverom av 2022-12-26 09:39:52.839 INFO (MainThread) [homeassistant.components.automation.varmekabler_pa_billigste_8_timer] Initialized trigger Varmekabler bad på billigste 12 timer 2022-12-26 09:39:52.839 INFO (MainThread) [homeassistant.components.automation.varmekabler_av_dyreste_timer] Initialized trigger Varmekabler av dyreste timer 2022-12-26 09:39:52.839 INFO (MainThread) [homeassistant.components.automation.varmekabler_vaskerom_pa_billigste_12_timer] Initialized trigger Varmekabler vaskerom på billigste 12 timer 2022-12-26 09:39:53.090 INFO (MainThread) [custom_components.hacs] Loading known repositories 2022-12-26 09:39:57.231 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:39:57.230674+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:39:57.232 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092736ff800000020106000011417d3e7e 2022-12-26 09:39:57.232 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:39:57.232594+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:39:57.233 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092738ff80000002010600001146e3477e 2022-12-26 09:39:57.422 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 54), 'active_power_import': 4417} 2022-12-26 09:39:57.422 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 54), 'active_power_import': 4417} 2022-12-26 09:39:57.428 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 56), 'active_power_import': 4422} 2022-12-26 09:39:57.429 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 56), 'active_power_import': 4422} 2022-12-26 09:39:57.483 INFO (SyncWorker_1) [homeassistant.loader] Loaded ffmpeg from homeassistant.components.ffmpeg 2022-12-26 09:39:57.662 INFO (MainThread) [homeassistant.setup] Setting up ffmpeg 2022-12-26 09:39:57.833 INFO (MainThread) [homeassistant.setup] Setup of domain ffmpeg took 0.2 seconds 2022-12-26 09:39:58.829 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:39:58.828864+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:39:58.830 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a0109273aff80000002010600001145c3777e 2022-12-26 09:39:58.870 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 58), 'active_power_import': 4421} 2022-12-26 09:39:58.871 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 39, 58), 'active_power_import': 4421} 2022-12-26 09:39:58.887 INFO (MainThread) [custom_components.hacs] Starting recurring background task for downloaded repositories 2022-12-26 09:39:58.889 INFO (MainThread) [custom_components.hacs] Stage changed: running 2022-12-26 09:40:00.733 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:00.733791+00:00, QOS 0, retain flagg False, and payload length 123 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:00.735 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea079010201108093e6e7000f40000000090c07e60c1a01092800ff800000020d09074b464d5f30303109103639373036333134303630323134383509084d41333034483345060000152b060000000006000000000600000217060000053106000058d6060000553106000009260600000000060000091823c47e 2022-12-26 09:40:00.747 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40), 'list_ver_id': 'KFM_001', 'meter_id': '6970631406021485', 'meter_type': 'MA304H3E', 'active_power_import': 5419, 'active_power_export': 0, 'reactive_power_import': 0, 'reactive_power_export': 535, 'current_l1': 1.329, 'current_l2': 22.742, 'current_l3': 21.809, 'voltage_l1': 234.2, 'voltage_l2': 0.0, 'voltage_l3': 232.8} 2022-12-26 09:40:00.747 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40), 'list_ver_id': 'KFM_001', 'meter_id': '6970631406021485', 'meter_type': 'MA304H3E', 'active_power_import': 5419, 'active_power_export': 0, 'reactive_power_import': 0, 'reactive_power_export': 535, 'current_l1': 1.329, 'current_l2': 22.742, 'current_l3': 21.809, 'voltage_l1': 234.2, 'voltage_l2': 0.0, 'voltage_l3': 232.8} 2022-12-26 09:40:00.748 DEBUG (MainThread) [custom_components.amshan.sensor] Ignore unhandled measure_id meter_datetime 2022-12-26 09:40:00.748 DEBUG (MainThread) [custom_components.amshan.sensor] Register new entities for measures: ['reactive_power_import_total', 'meter_id', 'list_ver_id', 'voltage_l2', 'current_l3', 'active_power_export', 'current_l2', 'voltage_l1', 'reactive_power_export', 'active_power_import', 'active_power_export_total', 'reactive_power_export_total', 'reactive_power_import', 'meter_manufacturer', 'active_power_import_total', 'voltage_l3', 'meter_type', 'current_l1'] 2022-12-26 09:40:00.861 DEBUG (MainThread) [custom_components.amshan.sensor] Restored state from 2022-12-25 22:00:11.218224+00:00 for sensor Kaifa-6970631406021485-reactive_power_import_total is too old to be used 2022-12-26 09:40:00.862 DEBUG (MainThread) [custom_components.amshan.sensor] Restored state from 2022-12-25 22:00:11.217764+00:00 for sensor Kaifa-6970631406021485-active_power_export_total is too old to be used 2022-12-26 09:40:00.863 DEBUG (MainThread) [custom_components.amshan.sensor] Use restored state from 2022-12-26 08:00:10.636371+00:00 for sensor Kaifa-6970631406021485-reactive_power_export_total 2022-12-26 09:40:00.863 DEBUG (MainThread) [custom_components.amshan.sensor] Use restored state from 2022-12-26 08:00:10.636714+00:00 for sensor Kaifa-6970631406021485-active_power_import_total 2022-12-26 09:40:02.099 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:02.098956+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:02.101 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092802ff80000002010600001144e5677e 2022-12-26 09:40:02.107 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 2), 'active_power_import': 4420} 2022-12-26 09:40:02.109 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 2), 'active_power_import': 4420} 2022-12-26 09:40:02.110 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4420 2022-12-26 09:40:02.111 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:04.067 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:04.067693+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:04.069 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092804ff800000020106000011394ac87e 2022-12-26 09:40:04.077 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 4), 'active_power_import': 4409} 2022-12-26 09:40:04.077 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 4), 'active_power_import': 4409} 2022-12-26 09:40:04.077 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4409 2022-12-26 09:40:04.078 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:06.336 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:06.336474+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:06.338 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092806ff8000000201060000113878db7e 2022-12-26 09:40:06.347 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 6), 'active_power_import': 4408} 2022-12-26 09:40:06.347 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 6), 'active_power_import': 4408} 2022-12-26 09:40:06.348 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4408 2022-12-26 09:40:06.349 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:07.492 INFO (MainThread) [homeassistant.components.light] Setting up light.twinkly 2022-12-26 09:40:07.496 INFO (MainThread) [homeassistant.components.light] Setting up light.twinkly 2022-12-26 09:40:07.616 INFO (MainThread) [homeassistant.components.twinkly.light] Twinkly '192.168.1.26' is now available 2022-12-26 09:40:07.630 INFO (MainThread) [homeassistant.components.twinkly.light] Twinkly '192.168.1.35' is now available 2022-12-26 09:40:08.005 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:08.005417+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:08.007 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a01092808ff80000002010600001134351c7e 2022-12-26 09:40:08.015 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 8), 'active_power_import': 4404} 2022-12-26 09:40:08.016 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 8), 'active_power_import': 4404} 2022-12-26 09:40:08.016 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4404 2022-12-26 09:40:08.017 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:10.330 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:10.330644+00:00, QOS 0, retain flagg False, and payload length 398 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:10.335 DEBUG (MainThread) [custom_components.amshan.metercon] Ignore JSON in payload without HDLC framing from topic pulse/publish: {'status': {'rssi': -65, 'ch': 6, 'ssid': '42-IoT', 'usbV': '1.35', 'Vin': '14.34', 'Vcap': '4.43', 'Vbck': '4.56', 'Build': '1.1.10', 'Hw': 'F', 'bssid': '245a4c1c2bcd', 'ID': 'fcf5c45540bc', 'Uptime': 471840, 'mqttcon': 0, 'pubcnt': 60, 'rxcnt': 60, 'wificon': 0, 'wififail': 0, 'bits': 68, 'cSet': 103, 'Ic': 0.0, 'crcerr': 0, 'cAx': 1.041766, 'cB': 14, 'heap': 212120, 'baud': 2400, 'meter': 'Kaifa', 'ntc': 22.07, 's/w': 0.0, 'ct': 0, 'dtims': 1214}} 2022-12-26 09:40:10.622 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:10.622287+00:00, QOS 0, retain flagg False, and payload length 123 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:10.624 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea079010201108093e6e7000f40000000090c07e60c1a0109280aff800000020d09074b464d5f30303109103639373036333134303630323134383509084d4133303448334506000011330600000000060000000006000002120600000526060000499506000045ff06000009260600000000060000091b12877e 2022-12-26 09:40:10.630 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 10), 'list_ver_id': 'KFM_001', 'meter_id': '6970631406021485', 'meter_type': 'MA304H3E', 'active_power_import': 4403, 'active_power_export': 0, 'reactive_power_import': 0, 'reactive_power_export': 530, 'current_l1': 1.318, 'current_l2': 18.837, 'current_l3': 17.919, 'voltage_l1': 234.2, 'voltage_l2': 0.0, 'voltage_l3': 233.1} 2022-12-26 09:40:10.631 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 10), 'list_ver_id': 'KFM_001', 'meter_id': '6970631406021485', 'meter_type': 'MA304H3E', 'active_power_import': 4403, 'active_power_export': 0, 'reactive_power_import': 0, 'reactive_power_export': 530, 'current_l1': 1.318, 'current_l2': 18.837, 'current_l3': 17.919, 'voltage_l1': 234.2, 'voltage_l2': 0.0, 'voltage_l3': 233.1} 2022-12-26 09:40:10.631 DEBUG (MainThread) [custom_components.amshan.sensor] Ignore unhandled measure_id meter_datetime 2022-12-26 09:40:10.631 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_id with state 6970631406021485 2022-12-26 09:40:10.631 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-list_ver_id with state KFM_001 2022-12-26 09:40:10.632 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-voltage_l2 with state 0.0 2022-12-26 09:40:10.632 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-current_l3 with state 17.919 2022-12-26 09:40:10.633 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_export with state 0 2022-12-26 09:40:10.633 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-current_l2 with state 18.837 2022-12-26 09:40:10.633 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-voltage_l1 with state 234.2 2022-12-26 09:40:10.634 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-reactive_power_export with state 530 2022-12-26 09:40:10.635 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4403 2022-12-26 09:40:10.636 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-reactive_power_import with state 0 2022-12-26 09:40:10.636 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:10.636 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-voltage_l3 with state 233.1 2022-12-26 09:40:10.637 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_type with state MA304H3E 2022-12-26 09:40:10.637 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-current_l1 with state 1.318 2022-12-26 09:40:12.291 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:12.291324+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:12.292 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a0109280cff80000002010600001136513a7e 2022-12-26 09:40:12.302 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 12), 'active_power_import': 4406} 2022-12-26 09:40:12.302 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 12), 'active_power_import': 4406} 2022-12-26 09:40:12.302 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4406 2022-12-26 09:40:12.303 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa 2022-12-26 09:40:14.260 DEBUG (MainThread) [custom_components.amshan.metercon] Message with timestamp 2022-12-26 08:40:14.260441+00:00, QOS 0, retain flagg False, and payload length 41 received from topic pulse/publish from subscription to topic pulse/publish 2022-12-26 09:40:14.262 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic pulse/publish: 7ea027010201105a87e6e7000f40000000090c07e60c1a0109280eff8000000201060000113a86f27e 2022-12-26 09:40:14.268 DEBUG (MainThread) [custom_components.amshan.sensor] Decoded meter message: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 14), 'active_power_import': 4410} 2022-12-26 09:40:14.269 DEBUG (MainThread) [custom_components.amshan.sensor] Received meter measures: {'meter_manufacturer': 'Kaifa', 'meter_datetime': datetime.datetime(2022, 12, 26, 9, 40, 14), 'active_power_import': 4410} 2022-12-26 09:40:14.269 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-active_power_import with state 4410 2022-12-26 09:40:14.270 DEBUG (MainThread) [custom_components.amshan.sensor] Update sensor Kaifa-6970631406021485-meter_manufacturer with state Kaifa ```
Screenshot 2022-12-26 at 09 23 49 Screenshot 2022-12-26 at 09 24 09
bendiksolheim commented 1 year ago

Just out of curiosity I tried making a Utility Meter, with reset cycle set to hourly, based on sensor.kaifa_active_power_import_total, and it shows the same behavior.

I was wondering if this was due to some time zone related issue, but it seems to me that the time zone is set correctly. Settings -> System -> General says (GMT+01:00) Oslo, and running the date command in the terminal correctly says Mon Dec 26 20:04:10 CET 2022 right now. It would also be weird if I was the only one with this problem if there was some time zone issue.

bendiksolheim commented 1 year ago

Thinking loudly here. It seems to me that sensor.kaifa_active_power_import_total changes state once every hour. This happens 11 seconds past a full hour (at least on my system). Does this mean the change in electricity usage will be on the wrong hour?

bendiksolheim commented 1 year ago

... and that is indeed the case here, it seems. The entities provided by amshan are not fit for usage in the energy dashboard by default. After talking to a few others, making an integration sensor over the live usage and using that as input to the energy dashboard is the correct way to go.

Closing this as I now have my desired result.