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

Fix fan.py #453

Merged
merged 2 commits into from
Jan 6, 2025
Merged

Fix fan.py #453

merged 2 commits into from
Jan 6, 2025

Conversation

arnpere
Copy link

@arnpere arnpere commented Jan 4, 2025

int conversion of string speed ranges provided by fan that led to below exception at HA start and hence deactivation of fan entities.

Exception in _update_handler when dispatching 'localtuya_bf753e0f5ece46fcb58mv4': ({'20': True, '22': 900, '23': 0, '60': False, '62': 1, '63': 'reverse', '64': 0},) Traceback (most recent call last): File "/config/custom_components/localtuya/entity.py", line 177, in _update_handler self.status_updated() ~~~~~~~~~~~~~~~~~~~^^ File "/config/custom_components/localtuya/fan.py", line 240, in status_updated self._percentage = ranged_value_to_percentage(

int conversion of string speed ranges provided by fan that led to below exception at HA start and hence deactivation of fan entities.

Exception in _update_handler when dispatching 'localtuya_bf753e0f5ece46fcb58mv4': ({'20': True, '22': 900, '23': 0, '60': False, '62': 1, '63': 'reverse', '64': 0},) Traceback (most recent call last): File "/config/custom_components/localtuya/entity.py", line 177, in _update_handler self.status_updated() ~~~~~~~~~~~~~~~~~~~^^ File "/config/custom_components/localtuya/fan.py", line 240, in status_updated self._percentage = ranged_value_to_percentage( 
~~~~~~~~~~~~~~~~~~~~~~~~~~^ self._speed_range, int(current_speed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 76, in ranged_value_to_percentage return scale_ranged_value_to_int_range(low_high_range, (1, 100), value) File "/usr/src/homeassistant/homeassistant/util/scaling.py", line 21, in scale_ranged_value_to_int_range source_offset = source_low_high_range[0] - 1 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ TypeError: unsupported operand type(s) for -: 'str' and 'int'
@xZetsubou
Copy link
Owner

How did you configure the device because normally config flow would only allows positive integer for min/max field, did you perhaps used auto configure?

@arnpere
Copy link
Author

arnpere commented Jan 5, 2025

How did you configure the device because normally config flow would only allows positive integer for min/max field, did you perhaps used auto configure?

Well, I'm not sure because this happened quite a long time ago. I used to use rospogrigio/localtuya since then (and devices were added using this version of localtuya), then moved recently to your fork since the other one stopped working after HA migrated to v2025.1. I only have fan & fan+lamp devices. All lamp devices continued to work fine but all fans stopped working right after the migration. Perhaps my configuration is very specific due to that history.

@xZetsubou xZetsubou merged commit 7a8852c into xZetsubou:master Jan 6, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants