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

device.limit_time unsupported operand type NoneType and float #87

Closed
6 of 7 tasks
dmz006 opened this issue Mar 1, 2024 · 10 comments · Fixed by #88
Closed
6 of 7 tasks

device.limit_time unsupported operand type NoneType and float #87

dmz006 opened this issue Mar 1, 2024 · 10 comments · Fixed by #88
Assignees
Labels
bug Something isn't working

Comments

@dmz006
Copy link

dmz006 commented Mar 1, 2024

System Health details

System Information

version core-2024.2.5
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.1
os_name Linux
os_version 6.1.73-haos-raspi
arch aarch64
timezone America/New_York
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.34.0
Stage running
Available Repositories 1407
Downloaded Repositories 14
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.0
update_channel stable
supervisor_version supervisor-2024.02.1
agent_version 1.6.0
docker_version 24.0.7
disk_total 28.5 GB
disk_used 3.5 GB
healthy true
supported true
board rpi3-64
supervisor_api ok
version_api ok
installed_addons Advanced SSH & Web Terminal (17.1.1)
Dashboards
dashboards 3
resources 6
views 5
mode storage
Recorder
oldest_recorder_run February 29, 2024 at 10:37 PM
current_recorder_run March 1, 2024 at 4:56 PM
estimated_db_size 6.15 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Nintendo Parental Controls mobile app

  • I have checked the configuration of the mobile app and the switch device is registered.
  • I experience this issue if I test again with the tested configuration in the readme.
  • This issue does not happen when tested with the tested configuration in the readme.

Describe the issue

I installed and configured the nintendo parential control plugin which appears to be working; however there appears to be a type error on limit_time (see below logs)

Reproduction steps

  1. Install HACS Nintendo Switch Parential Controls
  2. Install Integration for NSPC
  3. When configuring, copy and update access token following Invalid token provided #86
  4. Integration appears to work but then shows the errors provided
    ...

Debug logs

2024-03-01 17:46:35.198 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform nintendo_parental
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1325, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 549, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nintendo_parental/sensor.py", line 44, in native_value
    return self._device.limit_time - (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-01 17:46:35.279 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up nintendo_parental platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 352, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1325, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 549, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nintendo_parental/sensor.py", line 44, in native_value
    return self._device.limit_time - (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
2024-03-01 17:46:47.687 ERROR (MainThread) [custom_components.nintendo_parental] Unexpected exception from <bound method DataUpdateCoordinator.async_refresh of <custom_components.nintendo_parental.coordinator.NintendoUpdateCoordinator object at 0x7f61777080>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in _handle_timer_finish
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 289, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 412, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 549, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nintendo_parental/sensor.py", line 44, in native_value
    return self._device.limit_time - (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
2024-03-01 18:06:15.801 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 412, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 549, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nintendo_parental/sensor.py", line 44, in native_value
    return self._device.limit_time - (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

Diagnostics dump

No response

@JokerGermany
Copy link

Have this too, need to restart home assistant to let it work again.
For me it was bedtime_limit

@JokerGermany
Copy link

have to correct me, looks like it's not working anymore -__-

@pantherale0 pantherale0 self-assigned this Mar 4, 2024
@pantherale0 pantherale0 added the bug Something isn't working label Mar 4, 2024
@pantherale0
Copy link
Owner

Yes, I can replicate this when the parental controls app is set to not restricted. A new update will be released soon that has a couple of major changes, around this but also handling of the play time limit is now a number entity rather than time entity:

image

@JokerGermany
Copy link

Indeed playtime was set to unrestricted 🤔

@pantherale0 pantherale0 mentioned this issue Mar 4, 2024
@pantherale0
Copy link
Owner

Resolved in 2024.3.0 (released as beta)

@dmz006
Copy link
Author

dmz006 commented Mar 4, 2024

How do I set HACS to use the beta release so I can test?

@JokerGermany
Copy link

How do I set HACS to use the beta release so I can test?

  1. open hacs
  2. Integration
  3. Nintendo Switch Parental Controls
  4. 3 dots on top right
  5. retry downloading

@dmz006
Copy link
Author

dmz006 commented Mar 4, 2024

Thank you - been running for 20 minutes now and no errors.

@JokerGermany
Copy link

JokerGermany commented Mar 5, 2024

@pantherale0 I am asking because i have to change my scripts.
In the actual beta of

2024.3.0

only the variable name for play_time_limit was changed?
Am I correct?

@pantherale0
Copy link
Owner

Yes, the entity ID would have changed. Due to a previous change introduced in an earlier release it will probably include the name of the switch itself too.

To confirm what it is I would go into the Nintendo Switch device in Home Assistant (from the integrations page) and check the number. entity.

pantherale0 added a commit that referenced this issue Mar 7, 2024
Fix exception for user screen time sensor #87 
Fix authentication issues - #86 
Replace time entities with number entities - #84  
Remove bonus time - #81
Update readme - #89 
---------

Co-authored-by: Rob <robert.mclellan+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants