core: Error in lutron.py -- Hass.io loses ability to control LutronRA2 entities

Home Assistant release with the issue: 0.85.1

Last working Home Assistant release (if known): 0.84.6

Operating environment (Hass.io/Docker/Windows/etc.): RPi3, Hass.io

Component/platform: https://www.home-assistant.io/components/lutron/

Description of problem:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 287, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/light/lutron.py", line 73, in turn_off
    self._lutron_device.level = 0
  File "/usr/local/lib/python3.6/site-packages/pylutron/__init__.py", line 591, in level
    Output._ACTION_ZONE_LEVEL, "%.2f" % new_level)
  File "/usr/local/lib/python3.6/site-packages/pylutron/__init__.py", line 392, in send
    self._conn.send(op + out_cmd)
  File "/usr/local/lib/python3.6/site-packages/pylutron/__init__.py", line 91, in send
    self._send_locked(cmd)
  File "/usr/local/lib/python3.6/site-packages/pylutron/__init__.py", line 81, in _send_locked
    self._telnet.write(cmd.encode('ascii') + b'\r\n')
  File "/usr/local/lib/python3.6/telnetlib.py", line 290, in write
    self.sock.sendall(buffer)
TimeoutError: [Errno 110] Operation timed out

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

lutron:
  host: 192.168.1.225
  username: lutron
  password: integration

Traceback (if applicable):


Additional information:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 145 (69 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve pushed version 0.2.5 to pypi, will need to update HASS for new version and hopefully we can close this.

I found the bug. Proposing an edit now.

On Wed, Sep 4, 2019 at 3:04 PM Chris Heiser chris.heiser@gmail.com wrote:

HAH!!!

2019-09-04 17:14:15 DEBUG (Thread-3) [custom_components.lutron.cdhlutron] Uncaught exception: %d format: a number is required, not str

Of course… my logging of the exception is terrible so I don’t know yet exactly where it hit…

On Wed, Sep 4, 2019 at 2:57 PM grantalewis notifications@github.com wrote:

Never mind. Problem just occurred.

5:41 PM tried turning on

light.dining_room_dining_pendant light.family_room_family_recessed light.kitchen_kitchen_recessed

Lights would turn ON, but respective UI sliders toggled back to OFF

Was able to use Services to turn the entities off.

Light switches continued to work as did the Lutron app.

home-assistant.log.zip https://github.com/home-assistant/home-assistant/files/3576646/home-assistant.log.zip

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWXGPWSLXDUIEL2NW7LQIAVN3A5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD55D3OY#issuecomment-528104891, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWU4BHN2FQ637BTQW23QIAVN3ANCNFSM4GR2ZVYA .

I’m going to give it another go later on this afternoon. Maybe in an effort to get rid of extraneous login entries I deleted something important.

Thanks @thecynic ! Does this mean 99.2 contains the fix, or will it be the next version?

@Tangston311 Will be in the next version.

Once we go over the patch and get it submitted, the process is as follows:

  1. Update the version and push to pypi
  2. Submit a pull request to HA to update the version of pylutron. That pull request will be linked to this issue.
  3. HA will eventually release a new version, and include this issue as fixed in the release notes. That will be the time to remove the custom component.

On Thu, Sep 5, 2019 at 2:11 PM Tangston311 notifications@github.com wrote:

This is awesome - just want to echo @grantalewis https://github.com/grantalewis comments to say it’s amazing to see how dedicated all of you have been to solving this. This is why HA and this community are so incredible.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWT4LKJ4LVDZ47GWYOLQIFYYNA5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6AYWIQ#issuecomment-528583458, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWWPTVPSFV5NU5GTL3LQIFYYNANCNFSM4GR2ZVYA .

Checking in to say that it’s been smooth sailing all day long. Completely stoked to have this problem finally taken care of! Thanks to @cdheiser and @thecynic for your determination and patience.

I’d appreciate a recommendation on how long to leave the issue open. And also I’d appreciate your giving me a heads up on when to remove the custom component. (I know it’s not yet, but if you happen to know the version # that will include the fixed pylutron, please let me know.)

Once again, my thanks. If you guys were in my neighborhood I’d buy you a beer. Or three.

Pretty excited about this! Fingers crossed. I’ve got the new custom component installed on 0.98.3 and am going to let it run overnight. I also re-enabled my customary (non-mimimal) configuration.yaml, the OmniProBridge, and all automations, so I admit to throwing caution to the wind a bit. If things are still working in the AM, that’ll be a very good sign.

I still have all of the loggers enabled in case something goes wrong.

I think everything is there. This is really interesting. The last run of the background loop is at 17:55

2019-09-03 17:55:48 DEBUG (Thread-3) [custom_components.lutron.cdhlutron] Main run loop

It reads a change at 17:56: 2019-09-03 17:56:52 DEBUG (Thread-3) [custom_components.lutron.cdhlutron] Received line ~DEVICE,128,2,40 2019-09-03 17:56:52 INFO (Thread-3) [custom_components.lutron.cdhlutron] Updating 128(Fans 1): c=2 a=40 params=[] 2019-09-03 17:56:52 INFO (Thread-3) [custom_components.lutron.cdhlutron] Keypad: “Fans 1” Button name: “FamilyFan” num: 2 type: “Toggle” direction: “None” Action: 40 Params: []"

And then Thread-3 just goes silent… as if it’s wedged on something, or it’s just dead…

Once I don’t have a toddler nagging me, I’ll update the custom component one more time with some more instrumentation to see what’s happening to that thread. My guess is we’re throwing an uncaught exception, and it’s just killing the thread, and not getting logged.

On Tue, Sep 3, 2019 at 5:48 PM grantalewis notifications@github.com wrote:

This thought occurs: since I’m fairly unsure of what I’m looking for, there is the possibility that I’m inadvertently deleting something from the logs that I shouldn’t be. I don’t mind sharing my unaltered logs with you privately if you think that’s useful.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWRYBRZMSKDB77ECYS3QH4AT7A5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5Z7OZA#issuecomment-527693668, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWRP2U4OE2DDKHSPXIDQH4AT7ANCNFSM4GR2ZVYA .

I think I know what the problem is. I’ll send an updated custom component later today.

On Sat, Aug 31, 2019, 6:58 AM grantalewis notifications@github.com wrote:

Maybe I messed up something with your custom component? Here’s my config folder:

[image: Screen Shot 2019-08-31 at 9 52 56 AM] https://user-images.githubusercontent.com/9505044/64064890-3fc72880-cbd5-11e9-8036-4a6f0890db98.png

I did what you suggested and stripped back by configuration.yaml:

homeassistant: name: Home latitude: !secret my_latituide longitude: !secret my_longitude elevation: 228 unit_system: imperial time_zone: America/New_York customize: !include customize.yaml packages: !include_dir_named packages

http: api_password: !secret http_password base_url: !secret http_base_url ssl_certificate: /ssl/fullchain.pem ssl_key: /ssl/privkey.pem

hacs: token: !secret hacs_api_token sidepanel_title: Community

config:

system_health:

zone: !include zones.yaml

frontend:

discovery: ignore: - plex_mediaserver - netgear_router - igd - roku - samsung_tv

logbook:

emulated_hue: host_ip: 192.168.1.35 listen_port: 8300 expose_by_default: true exposed_domains: - light - switch - input_boolean

sensor: !include sensors.yaml

lutron: host: 192.168.1.225 username: <redacted> password: <redacted>

owntracks: track_new_devices: no max_gps_accuracy: 100 waypoints: true

mqtt: broker: localhost username: !secret mqtt_username password: !secret mqtt_password discovery: true discovery_prefix: homeassistant

input_boolean: dog_needs_food: name: Dog needs food icon: mdi:dog sitter_needs_greeting: bounty_switch: enable_zone7:

input_select: alarm_time: name: Alarm Time options: - Skip Tomorrow - 06:15 - 06:30 - 06:45 - 07:00 - 07:15 - 07:30 - Vacation icon: mdi:alarm

group: !include groups.yaml switch: !include switch.yaml

Even so, I’m not seeing anything about Custom Lutron Debug Mode or cdheiser. Just a log entry for “You are using a custom integration for lutron.”

2019-08-31 09:41:23 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant. 2019-08-31 09:41:23 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for lutron which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant. 2019-08-31 09:41:24 WARNING (MainThread) [homeassistant.components.http] Configuring api_password via the http integration has been deprecated. Use the legacy api password auth provider instead. For instructions, see https://www.home-assistant.io/docs/authentication/providers/#legacy-api-password 2019-08-31 https://www.home-assistant.io/docs/authentication/providers/#legacy-api-password2019-08-31 09:41:24 WARNING (MainThread) [homeassistant.components.http.auth] legacy_api_password support has been enabled. 2019-08-31 09:41:24 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=16 from 2019-08-31 13:31:01.840605) 2019-08-31 09:41:54 ERROR (MainThread) [homeassistant.components.mqtt.climate] Exception in async_discover when dispatching ‘mqtt_discovery_new_climate_mqtt’: ({‘current_temperature_topic’: ‘omnilink/thermostat1/current_temperature’, ‘temperature_low_state_topic’: ‘omnilink/thermostat1/temperature_heat_state’, ‘temperature_low_command_topic’: ‘omnilink/thermostat1/temperature_heat_command’, ‘temperature_high_state_topic’: ‘omnilink/thermostat1/temperature_cool_state’, ‘temperature_high_command_topic’: ‘omnilink/thermostat1/temperature_cool_command’, ‘min_temp’: ‘45’, ‘max_temp’: ‘95’, ‘mode_state_topic’: ‘omnilink/thermostat1/mode_state’, ‘mode_command_topic’: ‘omnilink/thermostat1/mode_command’, ‘modes’: [‘auto’, ‘off’, ‘cool’, ‘heat’], ‘fan_mode_state_topic’: ‘omnilink/thermostat1/fan_mode_state’, ‘fan_mode_command_topic’: ‘omnilink/thermostat1/fan_mode_command’, ‘fan_modes’: [‘auto’, ‘on’, ‘cycle’], ‘hold_state_topic’: ‘omnilink/thermostat1/hold_state’, ‘hold_command_topic’: ‘omnilink/thermostat1/hold_command’, ‘name’: ‘Lower Tstat’, ‘state_topic’: None, ‘availability_topic’: ‘omnilink/status’, ‘platform’: ‘mqtt’},) Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/climate.py”, line 244, in async_discover config = PLATFORM_SCHEMA(discovery_payload) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘state_topic’]

2019-08-31 09:41:54 ERROR (MainThread) [homeassistant.components.mqtt.climate] Exception in async_discover when dispatching ‘mqtt_discovery_new_climate_mqtt’: ({‘current_temperature_topic’: ‘omnilink/thermostat2/current_temperature’, ‘temperature_low_state_topic’: ‘omnilink/thermostat2/temperature_heat_state’, ‘temperature_low_command_topic’: ‘omnilink/thermostat2/temperature_heat_command’, ‘temperature_high_state_topic’: ‘omnilink/thermostat2/temperature_cool_state’, ‘temperature_high_command_topic’: ‘omnilink/thermostat2/temperature_cool_command’, ‘min_temp’: ‘45’, ‘max_temp’: ‘95’, ‘mode_state_topic’: ‘omnilink/thermostat2/mode_state’, ‘mode_command_topic’: ‘omnilink/thermostat2/mode_command’, ‘modes’: [‘auto’, ‘off’, ‘cool’, ‘heat’], ‘fan_mode_state_topic’: ‘omnilink/thermostat2/fan_mode_state’, ‘fan_mode_command_topic’: ‘omnilink/thermostat2/fan_mode_command’, ‘fan_modes’: [‘auto’, ‘on’, ‘cycle’], ‘hold_state_topic’: ‘omnilink/thermostat2/hold_state’, ‘hold_command_topic’: ‘omnilink/thermostat2/hold_command’, ‘name’: ‘Upper Tstat’, ‘state_topic’: None, ‘availability_topic’: ‘omnilink/status’, ‘platform’: ‘mqtt’},) Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/climate.py”, line 244, in async_discover config = PLATFORM_SCHEMA(discovery_payload) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data[‘state_topic’]

2019-08-31 09:42:00 WARNING (MainThread) [homeassistant.setup] Setup of lutron is taking over 10 seconds. 2019-08-31 09:42:17 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity raise HomeAssistantError(msg) 2019-08-31 09:42:17 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity raise HomeAssistantError(msg) 2019-08-31 09:42:17 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity raise HomeAssistantError(msg) 2019-08-31 09:42:17 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 399, in _async_add_entity raise HomeAssistantError(msg) 2019-08-31 09:42:22 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Family Room, the state is unknown. 2019-08-31 09:42:22 WARNING (MainThread) [homeassistant.components.template.sensor] Could not render template Master Bedroom, the state is unknown.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWQQSWO7EGNU5ZKS2VLQHJ2JBA5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TNIWI#issuecomment-526832729, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWXDYKFQGEMPWGALMKLQHJ2JBANCNFSM4GR2ZVYA .

Ok… I’m close to having something really simple, with some exception logging, and converting all debug logging to info logging since AFAICT, the logger doesn’t properly set components to debug, custom or otherwise.

On Fri, Aug 30, 2019 at 2:05 PM grantalewis notifications@github.com wrote:

I use a media_player custom component for Alexa and so am familiar with the process.

[image: Screen Shot 2019-08-30 at 5 01 43 PM] https://user-images.githubusercontent.com/9505044/64051188-465b8e80-cb48-11e9-87eb-03343c624a0e.png

I’m certainly willing to try.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWVVJCJNVOKGJ3QFEQTQHGDSZA5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5SZBLI#issuecomment-526749869, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWRPWGZHK3PBFRSPJJLQHGDSZANCNFSM4GR2ZVYA .

I upgraded to 0.98.0 this morning:

  • I tested a light using a toggle in the UI; everything worked for about 20 minutes
  • I tested another light using a toggle in the UI; the toggle stayed in the ON position but the light did not operate
  • went to Services and tested there; the light worked correctly
  • went back to the UI and tried there; the light worked
  • tried a couple of others and those worked, too

After 3 hours, the setup was still working and so I took a snapshot and restored it to my RPi3. Unfortunately that caused the problem to occur once again. I’m now going to go back to the Virtual Box install to see if that causes any different behavior.

EDIT 2 hours later: still solid, no problems. I’ll probably leave it running on Virtual Box to see how it behaves for the rest of the night. Then I’ll try the RPi3 again tomorrow.

Just by giving this a once over, it looks like you’re having network issues. Lutron isn’t mentioned until the very end, but it looks like alarm.com is having connectivity issues, as well as darksky and lutron… total guess, it’s hard to tell whats going on with this.

@grantalewis , just checking to see how creating the unique HA username is working for you. I’ve been running for 3 days now without the issue…just curious if you’re experiencing the same?

wow, this is great news! Please keep us posted. I’d love it if this was the cause…

The only time I ever suffer connection issues is when I reprogram or otherwise power cycle the main repeater.

On Sun, Aug 18, 2019 at 11:02 AM Jon Gilmore notifications@github.com wrote:

Also, I do not have a connect bridge. But as far as HA is concerned, we only talk to the Main repeater, and never the connect bridge, right?

Right, that’s correct. I’m just trying to figure out why only 2 people are facing this issue while others continue without issue. I imagine something has to be different/unique with their setups…

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/20348?email_source=notifications&email_token=ACQARWUCLPQBL5EYY7AFB2LQFGFETA5CNFSM4GR2ZVYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RE7TQ#issuecomment-522342350, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQARWW56OBOBRJVULOQOKDQFGFETANCNFSM4GR2ZVYA .

Ok I just added a second HA user for Lutron and applied that to my config as well.

I’m hopeful this will at least help… When I was testing last night with 2 diff HA setups using the same lutron username/password, I did see disconnects on the 2nd instance that started (but the instance kept re-connecting b/c of the re-connect code, lol)

@grantalewis You aren’t being stubborn 😃 I wanted to confirm whether or not we were losing communication with the lutron main repeater or if the issue is somewhere in HASS. Given that you can continue to change state via the API/service calls, it means that the underlying comms are good and the issue is in the HASS integration somewhere (either in HASS or in the callback mechanisms from pylutron)

@Tangston311 trying to reconcile your answer with @grantalewis… hmm

I don’t mean to be stubborn, but unless 0.84.6 is just more tolerant of borderline network issues, I just don’t think it’s network related. I have no problems with 0.84.6 whatsoever – not one, not ever.

I’m glad I found this because I’m experiencing exactly the same issue with HA and Ra2. At first everything seems to work just fine, but after an hour or so I experience the exact behavior seen in the video. My automations and service calls seems to still work just fine, but controlling through the front end becomes unusable.

Happy to do what I can to provide more info to help troubleshoot.

I’m on 93.1 using Hass.io.

Thats a good explanation, I appreciate it. The video helps me understand the behavior, which is different than I was understanding from your previous stuff in writing. Going to continue our convo on discord to keep this issue clean, if we come up with anything, we can post it here.

I had this same problem. Works for me in 0.86.4, failed when I updated to 0.88.1, I rolled back. I’m running HASS.IO in docker on Ubuntu 18.0.4 on a Laptop. Lutron Bridge is model L-BDG2

Error Log Entry:

2019-02-27 20:02:14 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/lutron_caseta/switch.py", line 33, in async_turn_on
    self._smartbridge.turn_on(self._device_id)
  File "/usr/local/lib/python3.7/site-packages/pylutron_caseta/smartbridge.py", line 190, in turn_on
    return self.set_value(device_id, 100)
  File "/usr/local/lib/python3.7/site-packages/pylutron_caseta/smartbridge.py", line 182, in set_value
    return self._writer.write(cmd)
AttributeError: 'NoneType' object has no attribute 'write'