make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.16k stars 471 forks source link

Madimack Pool heater Support #23

Closed mvnixon closed 3 years ago

mvnixon commented 3 years ago

Love the plugin - working perfectly with my Madimack pool heater!

Any aspirations to make a parallel plugin that supports Homebridge?

make-all commented 3 years ago

Homebridge is a different platform written in nodejs rather than python. It basically has nothing in common with Home Assistant, so I don't think there is any benefit in treating these as a common parallel plugin. There already seems to be an effort for providing Tuya support for Homebridge here: https://github.com/AMoo-Miki/homebridge-tuya-lan

make-all commented 3 years ago

But out of interest, there are two pool heaters supported, neither of which is Madimack, but I suspect the same devices (or controller boards at least) are being rebadged and sold under different brands in different markets. Which device is your pool heater detected as (you should see something in the log if the log level is set to at least INFO).

mvnixon commented 3 years ago

Sure - where do I adjust the log level?

make-all commented 3 years ago

In configuration.yaml I think is the only way. I have mine set to only enable INFO for my own integrations to reduce the noise in the log:

logger:
  default: warning
  logs:
    custom_components.tuya_local: info
mvnixon commented 3 years ago

Thanks!

This is what I get:

2021-06-21 08:13:18 INFO (MainThread) [custom_components.tuya_local.device] Creating device: 10568847c82b96120e36 2021-06-21 08:13:18 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for Pool-Heater to 3.3. 2021-06-21 08:13:19 INFO (MainThread) [custom_components.tuya_local.device] Pool-Heater inferring device type from cached state: {'1': True, '102': 9, '103': True, '104': 0, '105': 'warm', '106': 30, '107': 18, '108': 40, '115': 4, '116': 0, '117': True, '118': False, '120': 8, '122': 11, '124': 9, '125': 0, '126': 0, '127': 17, '128': 480, '129': 0, '130': False, '134': False, '135': False, '136': False, '139': False, '140': 'LowSpeed', 'updated_at': 1624227199.3927932} 2021-06-21 08:13:19 INFO (MainThread) [custom_components.tuya_local.device] Pool-Heater considering GardenPAC Pool Heatpump with quality 42

I read this as well where someone else has got it working: https://community.home-assistant.io/t/mr-silence-full-inverter-pool-heater/268960/4

make-all commented 3 years ago

OK, it looks like yours has a lot more options in there, but is reasonably compatible with the GardenPAC one.

mvnixon commented 3 years ago

Happy to test out any modifications or feature additions!

mvnixon commented 3 years ago

A small thing I've noticed - on Madimack pumps they use 'Boost' and 'Silence' terminology - rather than 'Silent' and 'Smart'. Smart seems to map to 'Boost' on Madimack.

mvnixon commented 3 years ago

Hi, an update I've found with the pool heater. If you turn off the device either through the Tuya app directly, or through the home assistant GUI, home assistant seems to loose contact with the device. It can only be restored by turning the device back on via the Tuya app, then rebooting home assistant. Here is the error messages:

`Logger: homeassistant.components.climate Source: custom_components/tuya_local/climate.py:28 Integration: Climate (documentation, issues) First occurred: 9:37:30 AM (1 occurrences) Last logged: 9:37:30 AM

Error while setting up tuya_local platform for climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/tuya_local/climate.py", line 60, in async_setup_entry await async_setup_platform(hass, {}, async_add_entities, discovery_info) File "/config/custom_components/tuya_local/climate.py", line 28, in async_setup_platform raise ValueError(f"Unable to detect type for device {device.name}") ValueError: Unable to detect type for device Pool-Heater`

Detection for Pool-Heater failed 9:37:30 AM – (WARNING) Tuya Local (custom integration) Failed to refresh device state for Pool-Heater. 9:37:29 AM – (ERROR) Tuya Local (custom integration)

make-all commented 3 years ago

It seems the heater is turning off completely. You might need the Wake on LAN integration to turn it on.

mvnixon commented 3 years ago

Hi, no I don't think it's that. I can turn the device back on from the Tuya app directly, and I can see the device is still connected to WiFi.

make-all commented 3 years ago

Do you have other logs from around that time that show the DPS the device is returning?

make-all commented 3 years ago

I have added this as a separate device in 0.8.4. To use it as the new device, you will have to remove and re-add the device. Make a note of your device id and local key before you remove it.

The only practical difference will be the naming of the preset mode, and the availability of more attributes.

The problem with the device being unrecognized when it is off may also be gone since 0.8.0, since I changed it to only auto-detect device type when the device is configured, not at every Home Assistant restart. This does mean the heater will need to be on when configuring it (or upgrading from 0.7.x to 0.8.x), so it is detected correctly. I'm not sure if that will fully fix the issue, but it should help.

mvnixon commented 3 years ago

Looking good from my end. Even when set to 'off' it seems to remain controllable. I'll keep an eye on it and let you know if anything breaks.

Happy to spend more time probing any unknown attributes as well to add more functionality - let me know!

Thanks

make-all commented 3 years ago

Any extra info about the "unknown" dps would help make it more complete. The same numbers/strings might be showing up in the official app which might help identify them.

mvnixon commented 3 years ago

Thanks. There is a timer function which could be some of the unknown DPS (although redundant in this setting). What it could relate to is error codes - there are a number that do come up on the official app, however I can't find anywhere in the App where the numbers/stings show up.

Happy to try and figure them out if you have any other ideas on how I can probe them!

make-all commented 3 years ago

Pool heaters normally have an error code for water flow. If you can shut the water off while the unit is running, you should be able to trigger that, and check the readings in the developer tools page of home assistant. It seems recently they made the data shown by developer tools non-live, so you may need to use the refresh button. With the number of true/false readings there, it may have a flag for each error condition in addition to a general numeric error code.

A lot of devices seem to use two DPS for the timer, one to set the timer (often in hours), and one that shows a countdown in minutes or seconds. The latter should be easy to find, but I'm not sure if the first one continues to reflect what the timer was set to, or if it always reads as 0 and is basically write only.

I found the manual for a modbus protocol for a similar pool heatpump, and it does seem to have a lot of measurements to do with the water flow rate/pressure/volume etc. Probably it will be difficult to figure out what is what without more info.

make-all commented 3 years ago

If you find any additional info that would be useful to have in the config (even if it is just naming attributes correctly), please make another report.