yangqian / hass-cozylife

third party cozylife integration
MIT License
66 stars 14 forks source link

Switch entity not working #1

Closed Daandeve closed 2 years ago

Daandeve commented 2 years ago

I can't get the switch entity to work, error below.

Error while setting up cozylife platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/cozylife/switch.py", line 39, in setup_platform
    _LOGGER.info(f'ip={hass.data[DOMAIN]}')
KeyError: 'cozylife'
yangqian commented 2 years ago

I will be receiving some switches soon and will test them.

Daandeve commented 2 years ago

Okay, when I remove this line _LOGGER.info(f'ip={hass.data[DOMAIN]}') the error is gone but the switch does not show. How can I debug this, custom_components.cozylife: debug does not work

yangqian commented 2 years ago

If you want to test by yourself, you can use a two-step approach.

  1. Test the python api by importing tcp_client in tcp_client.py
  2. Test the switch.py.

I guess I have not implemented setup_platform in switch.py yet.

yangqian commented 2 years ago

I have no idea of my recent commits work or not. If you want, you can test it out now. You have to change the "switchs" to "switches" in the config file.

Daandeve commented 2 years ago

I just fixed the problem the switches are working now, I'll create a pull request

Daandeve commented 2 years ago

Pull request opened #2

Daandeve commented 2 years ago

2 Merged in b5eb0d8c985e001ce6853d04438e34304e24aba7