Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues converting date and time, this may be causing problems with updating entity status #112

Open
Majestic7979 opened this issue Nov 22, 2024 · 6 comments

Comments

@Majestic7979
Copy link

This error originated from a custom integration.

Logger: custom_components.dirigera_platform
Source: custom_components/dirigera_platform/hub_event_listener.py:276
integration: IKEA Dirigera Hub Integration (documentation, issues)
First occurred: 1:56:13 AM (68 occurrences)
Last logged: 2:01:21 AM

Failed to convert 2024-11-22T02:01:13.000Z to date/time...
Failed to convert 2024-11-22T02:01:14.000Z to date/time...
Failed to convert 2024-11-22T02:01:23.000Z to date/time...
Failed to convert 2024-11-22T02:01:24.000Z to date/time...
Failed to convert 2024-11-22T02:01:25.000Z to date/time...

This was in my system logs in HA.

I am finding that FYRTUR is not updating it's open/close percentages so some automations aren't working - for instance sync curtains using a Zwave motor to the same percentage of the roller blinds.

The button to move the blinds UP in the HA UI is therefore not available (greyed out) because it thinks the roller blinds are always all the way up when they're in fact halfway. This is a real issue, makes the blinds uncontrollable.

It works fine in the Home Smart app.

I'd personally be super grateful for a fast fix if you know what's causing the issue and you're able to push an update, thanks so much for your work on this integration nonetheless, it's highly useful and with improvements can be even more so! Reliability is a pain point with zigbee, so your effort is recognized!

@tufo09
Copy link

tufo09 commented Dec 4, 2024

I have the same problem, i also get an error that it is not able to convert xy to date/time...
Id also be really grateful for a quick fix.

@JoeSzymkowicz
Copy link

The issue seems to lie in line 273 of hub_event_listener. It's calling 'datetime.datetime.strptime' instead of 'datetime.strptime'. After fixing this, it then throws more errors about missing timezone information, that I'm looking into now. The issue seems to solely be related to Commit 588be48.

@JoeSzymkowicz
Copy link

From what I can tell, after you fix the issue above, total_energy_consumed_last_updated attribute is missing tzinfo when setting entity state, unlike the other attributes. I'm fairly new to HA, so I will read up on the entity docs.

@sanjoyg
Copy link
Owner

sanjoyg commented Jan 2, 2025

Can you provide the dump json for me to fix it.

@tufo09
Copy link

tufo09 commented Jan 2, 2025

This should be all of it, i acually havent found a "END JSON" in my log file, so i hope this is all of it.
2025-01-02 10:28:07.542 INFO (SyncWorker_6) [custom_components.dirigera_platform] === START Devices JSON === 2025-01-02 10:28:07.543 INFO (SyncWorker_6) [custom_components.dirigera_platform] -------------- 2025-01-02 10:28:07.925 ERROR (SyncWorker_6) [custom_components.dirigera_platform] TYPE IS <class 'list'> 2025-01-02 10:28:07.925 INFO (SyncWorker_6) [custom_components.dirigera_platform] [{'id': 1, 'type': 'outlet', 'deviceType': 'outlet', 'createdAt': '2024-12-01T02:38:52.000Z', 'isReachable': True, 'lastSeen': '2025-01-02T09:28:06.000Z', 'attributes': {'customName': 'Smart plug 1', 'model': 'INSPELNING Smart plug', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '2.4.45', 'hardwareVersion': '1', 'serialNumber': 2, 'productCode': 'E2206', 'isOn': True, 'startupOnOff': 'startPrevious', 'lightLevel': 100, 'startUpCurrentLevel': -1, 'currentVoltage': 231.60000610351562, 'currentAmps': 1.097000002861023, 'currentActivePower': 203.3000030517578, 'totalEnergyConsumed': 79.08899688720703, 'totalEnergyConsumedLastUpdated': '2025-01-02T09:27:21.000Z', 'energyConsumedAtLastReset': 0, 'timeOfLastEnergyReset': '2024-12-01T01:33:51.000Z', 'childLock': False, 'statusLight': False, 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'permittingJoin': False, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoUpdate', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00'}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'isOn', 'lightLevel', 'energyConsumedAtLastReset', 'childLock', 'statusLight']}, 'room': {'id': 3, 'name': 'Bedroom', 'color': 'ikea_yellow_no_24', 'icon': 'rooms_bed'}, 'deviceSet': [], 'remoteLinks': [], 'isHidden': False}, {'id': 5, 'relationId': '69f2dcf8-3144-47bd-9075-66942b7314fd', 'type': 'gateway', 'deviceType': 'gateway', 'createdAt': '2024-10-28T11:46:27.823Z', 'isReachable': True, 'lastSeen': '2025-01-02T09:28:00.586Z', 'attributes': {'customName': 'Theo', 'model': 'DIRIGERA Hub for smart products', 'manufacturer': 'IKEA of Sweden', 'firmwareVersion': '2.685.0', 'hardwareVersion': 'P2.5', 'serialNumber': 5, 'identifyStarted': '2000-01-01T00:00:00.000Z', 'identifyPeriod': 0, 'otaStatus': 'upToDate', 'otaState': 'readyToCheck', 'otaProgress': 0, 'otaPolicy': 'autoDownload', 'otaScheduleStart': '00:00', 'otaScheduleEnd': '00:00', 'permittingJoin': False, 'backendConnected': False, 'backendConnectionPersistent': False, 'backendOnboardingComplete': True, 'backendRegion': 'eu-central-1', 'backendCountryCode': 'AT', 'userConsents': [{'name': 'analytics', 'value': 'disabled'}, {'name': 'diagnostics', 'value': 'enabled'}], 'logLevel': 3, 'coredump': False, 'timezone': 'Europe/Vienna', 'nextSunSet': None, 'nextSunRise': None, 'homestate': 'home', 'countryCode': 'XZ', 'isOn': False}, 'capabilities': {'canSend': [], 'canReceive': ['customName', 'permittingJoin', 'userConsents', 'logLevel', 'time', 'timezone', 'countryCode', 'coordinates']}, 'deviceSet': [], 'remoteLinks': []}]

@Makifun
Copy link

Makifun commented Jan 19, 2025

My log is also being filled up with errors about datetime(filling up the disk) so I figured I'd also add my log entries here. My log is being filled with the below(minus debug info which i temporarily enabled just now) multiple times per second.

2025-01-19 23:41:46.756 DEBUG (Thread-4) [custom_components.dirigera_platform] rcvd message : {"id":"a111de32-86e7-40f8-8945-deb599c34e5a","time":"2025-01-19T22:41:45.729Z","specversion":"3.164.0","source":"urn:com:ikea:homesmart:iotc:zigbee","type":"deviceStateChanged","data":{"id":"ae003952-dfef-48bf-bede-b1ffe12d87cb_1","type":"outlet","deviceType":"outlet","createdAt":"2024-10-17T19:58:41.000Z","isReachable":true,"lastSeen":"2025-01-19T22:41:45.000Z","attributes":{"currentAmps":0.3840000033378601},"remoteLinks":[]}} 2025-01-19 23:41:46.756 DEBUG (Thread-4) [custom_components.dirigera_platform] device type of message outlet 2025-01-19 23:41:46.756 DEBUG (Thread-4) [custom_components.dirigera_platform] Setting ae003952-dfef-48bf-bede-b1ffe12d87cb_1 reachable as True 2025-01-19 23:41:46.756 DEBUG (Thread-4) [custom_components.dirigera_platform] setting current_amps to 0.3840000033378601

2025-01-19 23:41:46.756 DEBUG (Thread-4) [custom_components.dirigera_platform] Entity before setting: id='ae003952-dfef-48bf-bede-b1ffe12d87cb_1' relation_id=None type='outlet' device_type='outlet' created_at=datetime.datetime(2024, 10, 17, 19, 58, 41, tzinfo=TzInfo(UTC)) is_reachable=True last_seen=datetime.datetime(2025, 1, 19, 22, 34, 13, tzinfo=TzInfo(UTC)) attributes=OutletAttributes(custom_name='Dedotated wam', model='INSPELNING Smart plug', manufacturer='IKEA of Sweden', firmware_version='2.4.45', hardware_version='1', serial_number='08DDEBFFFED79F70', product_code='E2206', ota_status='upToDate', ota_state='readyToCheck', ota_progress=0, ota_policy='autoUpdate', ota_schedule_start=datetime.time(0, 0), ota_schedule_end=datetime.time(0, 0), is_on=True, startup_on_off=<StartupEnum.START_PREVIOUS: 'startPrevious'>, status_light=False, identify_period=0, permitting_join=False, energy_consumed_at_last_reset=0.0, current_active_power=66.0999984741211, current_amps=0.4059999883174896, current_voltage=231.6999969482422, total_energy_consumed=176.3470001220703, total_energy_consumed_last_updated='2025-01-19T22:41:37.000Z', time_of_last_energy_reset=datetime.datetime(2024, 10, 17, 18, 57, tzinfo=TzInfo(UTC))) capabilities=Capabilities(can_send=[], can_receive=['customName', 'isOn', 'lightLevel', 'energyConsumedAtLastReset', 'childLock', 'statusLight']) room=Room(id='19bfae5e-f329-4094-a6fc-622d92347351', name='Kök1', color='ikea_green_no_65', icon='rooms_cutlery') device_set=[] remote_links=[] is_hidden=False dirigera_client=<custom_components.dirigera_platform.dirigera_lib_patch.HubX object at 0x72653f9a4550>

2025-01-19 23:41:46.757 DEBUG (Thread-4) [custom_components.dirigera_platform] Entity after setting: id='ae003952-dfef-48bf-bede-b1ffe12d87cb_1' relation_id=None type='outlet' device_type='outlet' created_at=datetime.datetime(2024, 10, 17, 19, 58, 41, tzinfo=TzInfo(UTC)) is_reachable=True last_seen=datetime.datetime(2025, 1, 19, 22, 34, 13, tzinfo=TzInfo(UTC)) attributes=OutletAttributes(custom_name='Dedotated wam', model='INSPELNING Smart plug', manufacturer='IKEA of Sweden', firmware_version='2.4.45', hardware_version='1', serial_number='08DDEBFFFED79F70', product_code='E2206', ota_status='upToDate', ota_state='readyToCheck', ota_progress=0, ota_policy='autoUpdate', ota_schedule_start=datetime.time(0, 0), ota_schedule_end=datetime.time(0, 0), is_on=True, startup_on_off=<StartupEnum.START_PREVIOUS: 'startPrevious'>, status_light=False, identify_period=0, permitting_join=False, energy_consumed_at_last_reset=0.0, current_active_power=66.0999984741211, current_amps=0.3840000033378601, current_voltage=231.6999969482422, total_energy_consumed=176.3470001220703, total_energy_consumed_last_updated='2025-01-19T22:41:37.000Z', time_of_last_energy_reset=datetime.datetime(2024, 10, 17, 18, 57, tzinfo=TzInfo(UTC))) capabilities=Capabilities(can_send=[], can_receive=['customName', 'isOn', 'lightLevel', 'energyConsumedAtLastReset', 'childLock', 'statusLight']) room=Room(id='19bfae5e-f329-4094-a6fc-622d92347351', name='Kök1', color='ikea_green_no_65', icon='rooms_cutlery') device_set=[] remote_links=[] is_hidden=False dirigera_client=<custom_components.dirigera_platform.dirigera_lib_patch.HubX object at 0x72653f9a4550>

2025-01-19 23:41:46.757 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity._async_write_ha_state_from_call_soon_threadsafe() (None) Traceback (most recent call last): File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/homeassistant/helpers/entity.py", line 1014, in _async_write_ha_state_from_call_soon_threadsafe self._async_write_ha_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/local/lib/python3.13/site-packages/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state self.__async_calculate_state() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/usr/local/lib/python3.13/site-packages/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state state = self._stringify_state(available) File "/usr/local/lib/python3.13/site-packages/homeassistant/helpers/entity.py", line 1029, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/homeassistant/components/datetime/__init__.py", line 106, in state if value.tzinfo is None: ^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'tzinfo'

Edit:
If anyone is using docker and wants to extend their SSDs lifetime you can disable logging to disk(multiple times a second) like this in docker compose:
homeassistant:
image: lscr.io/linuxserver/homeassistant
logging:
driver: none

To also disable the log in homeassistant itself you can make it immutable like so:
rm home-assistant.log
touch home-assistant.log
sudo chattr +i home-assistant.log

Hopefully this gets fixed so that logs can be enabled again. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants