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

Wall switches with fan entity not adding properly. #93

Closed
Wheemer opened this issue Jan 2, 2024 · 13 comments
Closed

Wall switches with fan entity not adding properly. #93

Wheemer opened this issue Jan 2, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@Wheemer
Copy link

Wheemer commented Jan 2, 2024

Hello;

I have three wall switches with fan control that fail to add properly, even with downloading the latest files and overwriting.

"Referenced entities fan.kitchen_fan_switch are missing or not currently available"

@Wheemer Wheemer added the bug Something isn't working label Jan 2, 2024
@xZetsubou
Copy link
Owner

xZetsubou commented Jan 2, 2024

I don't understand what do you mean "wall switches with fan entity"? there's either fan device or switch device.
Maybe posting device diagnostic or entry diagnostic may help me to understand.

Also check the logs HA -> Settings -> System -> Logs. search for localtuya and check errors etc...

@Wheemer
Copy link
Author

Wheemer commented Jan 2, 2024

Sorry, they are wall switch fan controllers with a light also. Two of the same and one slightly different.

localtuya-359e0e0476eb0c83ec7828fed048427e-Diningroom Fan Switch-a1e70c7671d138a3ba7ac6e690e64bf3.json.txt

localtuya-359e0e0476eb0c83ec7828fed048427e-Kitchen Fan Switch-d914788c819d91b8337529adf6f0b3bb.json.txt

localtuya-359e0e0476eb0c83ec7828fed048427e-Moms Fan Switch-4b7582589c9f020dc12632080de8e367.json.txt

Exception in _update_handler when dispatching 'localtuya_03585705a4e57c93e407': ({'1': False, '3': '1', '6': '0', '7': 0, '9': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 547, in _update_handler self.status_updated() File "/config/custom_components/localtuya/fan.py", line 236, in status_updated self._percentage = ranged_value_to_percentage( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 79, 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 20, in scale_ranged_value_to_int_range source_offset = source_low_high_range[0] - 1 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' Exception in _update_handler when dispatching 'localtuya_03585705a4e57c13a324': ({'1': False, '3': '2', '6': '0', '7': 0, '9': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 547, in _update_handler self.status_updated() File "/config/custom_components/localtuya/fan.py", line 236, in status_updated self._percentage = ranged_value_to_percentage( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 79, 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 20, in scale_ranged_value_to_int_range source_offset = source_low_high_range[0] - 1 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' Exception in _update_handler when dispatching 'localtuya_ebf9ddc41254c3b58ayjwa': ({'1': False, '4': 100, '5': False, '13': True},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 547, in _update_handler self.status_updated() File "/config/custom_components/localtuya/fan.py", line 236, in status_updated self._percentage = ranged_value_to_percentage( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 79, 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 20, in scale_ranged_value_to_int_range source_offset = source_low_high_range[0] - 1 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

@xZetsubou
Copy link
Owner

It seems that I forgot to set default min and max fan speed and this what causing the error. delete your devices to test install master version re-configure the devices.

To install master version via HACS.

Go HACS -> Local Tuya -> On top right corner click on the ⋮ and choose redownload and select master

HACS Select version

image

Restart HA and re-configure the devices.

@Wheemer
Copy link
Author

Wheemer commented Jan 2, 2024

Thanks a lot! It's working perfect now.

@xZetsubou
Copy link
Owner

When new version release comes out update to it via HACS, it's not good to stay on "master version"

@Wheemer
Copy link
Author

Wheemer commented Jan 3, 2024

Hello;

I seem to be missing the preset modes for two of them that have actual hi med low buttons. Although presets for all three would be nice.

@xZetsubou
Copy link
Owner

xZetsubou commented Jan 3, 2024

I haven't made changes in FAN ever since I forked this repo and originally there is no "preset modes" in upstream repo,
so I'm guessing I may need to add this, Tho If I add it later on it still require re-configure.

edit
Where do you see this preset modes that is missing in Home Assistant because I can't find preset or mode DP in your device DPS data.

edit2
Can you change something in your Kitchen Fan Switch device
Go to HA -> localtuya integration page -> click configure -> Choose reconfigure existing device -> Select Kitchen Fan then submit and submit again until you see fan configuration in the last field fan modes list type: 1,2,3 then submit until it saves, after that check fan speed again

@Wheemer
Copy link
Author

Wheemer commented Jan 3, 2024

Hello;

I tried what you suggested and there seems to be no change, or else I can't see the presets anywhere.

I think I may have had to build the presets using select in the previous version, but it's been too long to remember properly.

Both moms fan and kitchen have just low, medium and high buttons on the panel.

@xZetsubou
Copy link
Owner

xZetsubou commented Jan 3, 2024

To there are fans that are actually supports "preset modes" but yours doesn't support that but the different in your fans is.

Diningroom Fan: Has controllable speed 1-100. which.
Kitchen Fan: Has only 3 controllable speeds: 1-2-3, and the normal way is to add like I suggest in modes list.

But in reality your fans doesn't have modes, if you check Tuya docs you will see missing DPS in your fans mode https://developer.tuya.com/en/docs/iot/f?id=K9gf45vs7vkge

So your fan supports 3 speeds not 3 modes ^^

@Wheemer
Copy link
Author

Wheemer commented Jan 3, 2024

When using the fan turn on service I am only offered percentage and not speed mode or anything else.

@xZetsubou
Copy link
Owner

xZetsubou commented Jan 3, 2024

Just set the percentage that you want home assistant will convert percentage to a value that can be used for the device.
https://developers.home-assistant.io/docs/core/entity/fan/#set-speed-percentage
using percentage_to_ordered_list_item utility

edit if you want to check if you fan changed value or not you can listen to devices DP if it changes.
Go to HA -> developer-tools -> event . http://ip:8123/developer-tools/event
In the event subscribe field to type this: localtuya_device_dp_triggered or localtuya_states_update then start listening after that control and check in HA what DP triggered and the values that triggered the DP.

@Wheemer
Copy link
Author

Wheemer commented Jan 3, 2024

Hello;

I think it was changing the "max fax speed integer" to 3 that made it work. I put the list back to disabled and it's still ok in the interface. Now I see just off 1 2 3. However in calling service fan on it still only presents me with a percentage slider. No matter what percent I choose it only stays on speed 1.

@Wheemer
Copy link
Author

Wheemer commented Jan 3, 2024

Never mind it's working now. I blasted it out and readded it after a reboot.

Thanks!

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

No branches or pull requests

2 participants