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

SYSVAR suport ? #7

Open
ronluna opened this issue Sep 23, 2023 · 45 comments
Open

SYSVAR suport ? #7

ronluna opened this issue Sep 23, 2023 · 45 comments

Comments

@ronluna
Copy link

ronluna commented Sep 23, 2023

Possible to add support to monitoring and setting custom variable (SYSVAR)?

image

image

@rzulian
Copy link
Owner

rzulian commented Oct 4, 2023

@ronluna Do you have an example of what you want to do?

@ronluna
Copy link
Author

ronluna commented Oct 4, 2023

When adding actions to Button press, Double Tap and Hold . the only way to prevent the Button press actions from running when Double tapping or holding the button is by creating custom actions and then stopping those actions before executing whatever is on Double tap or Hold . as explained here

image

This forces the programming to create custom variables to track what to do when next button press happens (For toggle situations etc) in lutron and if this buttons presses events are being used trigger other devices inside HA then devices get out of sync between the two systems as currently there is no way to monitor/set SYSVAR from HA. By enabling this feature it will help keeping track and in sync this type of events.

@rzulian
Copy link
Owner

rzulian commented Nov 26, 2023

@ronluna I've checked that we can monitor System Variables for the variables that have an Integration ID. It seems that get the corresponding state number, but not the value (e.g in your case your are getting a 0 and not State 001). I've checked the Lutron database, and I cannot find a reference to the possible values, at least on what's exported with my old version of the Lutron firmware.
Does a sensor for each Variable work?

@ronluna
Copy link
Author

ronluna commented Nov 30, 2023

I think a sensor in Home assistant that reflects the state of the the lutron sysvar would be great, Would it be possible to change/set the lutron sysvar value though HA's sensor ?

@ronluna
Copy link
Author

ronluna commented Mar 25, 2024

Hello Riccardo,
I've decided to merge your changes with the latest pylutron and hass lutron component, It was the only way to be able to assign entities to areas by using uuid this will allow to prepare hass for the voice assistant revolution that is happenning as we speak... It's not perfect... maybe you can check it out when you have a moment as currently there are a few things I was unable to get work properly (mainly the naming of the areas and including the names of the areas in the entities itself) .

pylutron https://github.com/ronluna/pylutron
lutron component https://github.com/ronluna/ha_core/tree/dev/homeassistant/components/lutron

@rzulian
Copy link
Owner

rzulian commented Mar 26, 2024

Hey Ron,
I'll try, probably next week.
Could you please create the pull requests?

@txwindsurfer
Copy link

txwindsurfer commented Apr 4, 2024

@rzulian I just updated to Home Assistant Core 2024.4.0 and my integration to Lutron QS broke. Did any files change from HA Core 2024.3.3 which works for me and 2024.4.0. I am not getting any log errors but the lights are no longer responsive. I can send logs etc. but fist wanted to confirm that something changed.

Confirmed #114794 is a solid fix and all is good.

@rzulian
Copy link
Owner

rzulian commented May 3, 2024

@ronluna
I've completed the check.
You can find the new lutron component here: https://github.com/rzulian/core/tree/ron
and the pylutron here https://github.com/rzulian/pylutron/tree/homeworks-support

Could you please check that everything is working fine on your side?
I've added in the config flow the possibility to:
flag if you want to refresh data from Lutron each time you instantiate the integration
flag if you want to use the full path as area name, which is useful if your layout has areas included in other areas
flag if you want to prepend the area name to the device name (e.g you have multiple lights named "Applique", in multiple rooms. Using this flag you will have room1 Applique, room2 Applique, etc)

@clementx2006
Copy link

@rzulian

Thanks for the above - was just going to ask if you were going to update the custom component to allow better integration with the latest HA!

Could I double check before I go upgrade my HA to the latest: I only need to copy the files in Lutron folder and put it in custom_components (well after adjusting the manifest to point to the pylutron fork above)?

@ronluna
Copy link
Author

ronluna commented May 3, 2024

Hello @rzulian, thanks for taking the time in looking at this and making it much better, although, I believe the requirements for the Lutron component in the manifest.json file needs to be adjusted to:

git+https://github.com/rzulian/pylutron.git@homeworks-support
or
git+https://github.com/rzulian/pylutron.git@homeworks-support-ron ?

I was about to suggest:

  • The possibility to allow adding multiple processors to the addon's flow, this is uncommon but I've in that situation before.
  • Support for SYSVAR. I keep getting lost in pylutron to properly add support for it.
  • I also think it might be wise for change the component's domain to something other than Lutron turning this component into a real alternative to the official one that only supports RA2.

I wanted to confirm the above before testing as currently I can only test in a live system and I'm trying to prevent complains... lol

@rzulian
Copy link
Owner

rzulian commented May 4, 2024

@ronluna @clementx2006 Just add "requirements": ["git+https://github.com/rzulian/pylutron.git@homeworks-support#pylutron==0.2.6"], to the manifest.json
@ronluna as soon I've confirmed this version, I'll work on the SYSVAR.
Regarding the component's domain. I've reached out to the maintainers of pylutron and the lutron component to understand if they are willing to help, or if we have to fork.
Regarding the multiple processors. We will need to change the telnet lib soon, so we can evaluate it.

@rzulian
Copy link
Owner

rzulian commented May 4, 2024

@txwindsurfer could you please check latest version?

@ronluna
Copy link
Author

ronluna commented May 5, 2024

Hello @rzulian,

After implementing the above I've noticed the following:

There is a new file named event.py being used to identify button types and events, I believe this was previously being handled in the component's init.py file around line 134 as

        ev_map = {
            Button.Event.PRESS: "press",
            Button.Event.RELEASE: "release",
            Button.Event.HOLD: "hold",
            Button.Event.DOUBLE_TAP: "double_tap",
            Button.Event.HOLD_RELEASE: "hold_release"
        }

This mapping gave the ability to trigger event during more situation as hold and double_tap but are nowhere to be seen in the new update, I believe this other events are very important (Well I'm currently using them quite often).

also the event.py is causing an exception when any button is pressed on any keypad (as seen below)

Logger: pylutron
Source: /usr/local/lib/python3.12/site-packages/pylutron/__init__.py:217
First occurred: 10:46:10 AM (1 occurrences)
Last logged: 10:46:10 AM

Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 215, in run
    self._main_loop()
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 206, in _main_loop
    self._recv_cb(line.decode('ascii').rstrip())
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 568, in _recv
    handled = obj.handle_update(args)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 1193, in handle_update
    return self._components[component].handle_update(action, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 1039, in handle_update
    self._dispatch_event(ev_map[action], {})
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 707, in _dispatch_event
    handler(self, context, event, params)
  File "/config/custom_components/lutron/event.py", line 97, in handle_event
    elif event == Button.Event.PRESSED:
                  ^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Event' has no attribute 'PRESSED'. Did you mean: 'PRESS'?

I tried editing the event.py file around line 90 to this:

        """Handle received event."""
        action: LutronEventType | None = None
        if self._has_release_event:
            #if event == Button.Event.PRESSED:
            if event == Button.Event.PRESS:
                action = LutronEventType.PRESS
            else:
                action = LutronEventType.RELEASE
        #elif event == Button.Event.PRESSED:
        elif event == Button.Event.PRESS:
            action = LutronEventType.SINGLE_PRESS

But another exception came up and I think it would be better to be checked on your end as currently this system is live and it relies on the double tap and hold events to trigger other things (They will also complain pretty soon)...

Hope my comments were helpful.

@rzulian
Copy link
Owner

rzulian commented May 5, 2024

@ronluna it looks like HA is using the standard pylutron. Are you using a custom component or did you replace the lutron component itself?

@ronluna
Copy link
Author

ronluna commented May 5, 2024

Im certain HA was using the pylutron you’ve specified above . I even uninstalled it and reinstalled manually from within the ha docker instance and using pip show pylutron would show the correct library (your library 0. 2.5).

homeassistant:/config# pip3 install git+https://github.com/rzulian/pylutron.git@homeworks-support#pylutron==0.2.6
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting git+https://github.com/rzulian/pylutron.git@homeworks-support#pylutron==0.2.6
  Cloning https://github.com/rzulian/pylutron.git (to revision homeworks-support) to /tmp/pip-req-build-eqbwu1hs
  Running command git clone --filter=blob:none --quiet https://github.com/rzulian/pylutron.git /tmp/pip-req-build-eqbwu1hs
  Running command git checkout -b homeworks-support --track origin/homeworks-support
  branch 'homeworks-support' set up to track 'origin/homeworks-support'.
  Switched to a new branch 'homeworks-support'
  Resolved https://github.com/rzulian/pylutron.git to commit e8c6c1867c032108d78d767aae1f4d495e53d9bf
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pylutron
  Building wheel for pylutron (setup.py) ... done
  Created wheel for pylutron: filename=pylutron-0.2.5-py3-none-any.whl size=15289 sha256=7a7501e6d7dcffb1d1eeb4db119498efcfd24b6e518ab3bc1ea9c157613fd3a0
  Stored in directory: /tmp/pip-ephem-wheel-cache-fbi46f6c/wheels/9f/3f/b7/ed6f80024efae9458d8004479dbf432b1708d69a1130445127
Successfully built pylutron
Installing collected packages: pylutron
Successfully installed pylutron-0.2.5
homeassistant:/config# pip show pylutron
Name: pylutron
Version: 0.2.5
Summary: Python library for Lutron RadioRA 2 and HomeWorks
Home-page: http://github.com/thecynic/pylutron
Author: Dima Zavin
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.12/site-packages
Requires: 
Required-by: 

When I go back to my version of pylutron and replaced the lutron folder with my files back inside the custom_component folder everything works again .

I had to manually uninstall your pylutron library and reinstalled mine.

wondering if your latest version is currently running on your system ?

@rzulian
Copy link
Owner

rzulian commented May 5, 2024

Old custom component was using my pylutron via "requirements"["git+https://github.com/rzulian/pylutron.git@homeworks-support#pylutron==0.2.6"],
In this version of pylutron the event was already PRESS, not PRESSED, and the custom component was triggering events accordingly.

New component in my test environment.
Pylutron is installed locally using pip3 install -e ../pylutron
The lutron integration is running in the 'ron' branch, using hass --skip-pip-packages pylutron . Note that I've removed the "requirements" in the manifest.json.

@ronluna From your error log it seems that your are not using my lutron integration, because this error File "/config/custom_components/lutron/event.py", line 97, in handle_event elif event == Button.Event.PRESSED: is the current lutron integration (aka the radiora version, with the PRESSED event, using the official pylutron). Could you please double check? Did I miss something?

@ronluna
Copy link
Author

ronluna commented May 6, 2024

Hello @rzulian, I've tried again this morning and I have the following to share:

I had to delete the previous component as later I've noticed the proper component was not being loaded as I had two components using the same domain, after doing that everything started to flow as expected although I have the following suggestion,

Would be nice to add labels to each check box for the Area creation and device naming options (as seen below)
Screenshot 2024-05-06 at 09 19 33

Also the component is currently crashing on my end after a button press event occurs, any ideas?

Logger: pylutron

Source: /usr/local/lib/python3.12/site-packages/pylutron/__init__.py:217
First occurred: 9:32:31 AM (2 occurrences)
Last logged: 9:56:49 AM

Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 215, in run
    self._main_loop()
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 206, in _main_loop
    self._recv_cb(line.decode('ascii').rstrip())
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 568, in _recv
    handled = obj.handle_update(args)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 1193, in handle_update
    return self._components[component].handle_update(action, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 1039, in handle_update
    self._dispatch_event(ev_map[action], {})
  File "/usr/local/lib/python3.12/site-packages/pylutron/__init__.py", line 707, in _dispatch_event
    handler(self, context, event, params)
  File "/config/custom_components/lutron/event.py", line 125, in handle_event
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state
    self.hass.verify_event_loop_thread("async_write_ha_state")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'lutron' calls async_write_ha_state from a thread at custom_components/lutron/event.py, line 125: self.async_write_ha_state(). Please report it to the author of the 'lutron' custom integration.

I had to revent back to the previous component as this is a live system.

any inputs would appreciated.

@ronluna
Copy link
Author

ronluna commented May 6, 2024

Ok, it's working.

I had to change line 125 on event.py to:

        #self.async_write_ha_state()
        self.schedule_update_ha_state()

As Home assistant 2024.5.1 does not like async_write_ha_state due to "unsafe thread writes." .

@rzulian
Copy link
Owner

rzulian commented May 6, 2024

I was about to ask you which HA core version you were using ... ;)
BTW, there is a new commit that is adding the option for the device_name also for the keypad components.
I've noticed that the options sometimes do not have the labels. I've not clue, I'll investigate it.

@rzulian
Copy link
Owner

rzulian commented May 7, 2024

@ronluna regarding the variables. Could you please check in your exported xml, if you have references to the variables?
In my exported xml, there isn't a section referring to the variables. Some of them are listed in timeclock events.
We have two options:

  1. we create a fake timeclock event on the Lutron side,
  2. we ask for a list of the variables' ids in the HA integration

What do you think about it?

@ronluna
Copy link
Author

ronluna commented May 7, 2024

Wondering what's the purpose of the fake timeclock?
The xml makes no references of any of the system variable that the project has. Although the Integration report does show all the system's variable with the integration ID. What if the system variable are manually created on the HA side (as a feature of the config flow) using the integration id from the Lutron report so HA would know what to do when does ids pop in pylutron?

image

@rzulian
Copy link
Owner

rzulian commented May 7, 2024

Wondering what's the purpose of the fake timeclock?

If you create a dummy timeclock in Lutron, with the variables that you need, we could get the list of the variables from the XML instead of

. What if the system variable are manually created on the HA side (as a feature of the config flow) using the integration id from the Lutron report so HA would know what to do when does ids pop in pylutron?

which is solution 2 in my proposal.

@ronluna
Copy link
Author

ronluna commented May 7, 2024

It is indeed a more elegant solution to not have to get hands dirty finding out integrations id for the SYSVARs...

Let's do your way!!!! 👍

@txwindsurfer
Copy link

@txwindsurfer could you please check latest version?

@rzulian I replaced the pylutron file with the one at https://github.com/rzulian/pylutron that added the line for HWI_SLIM keypad. Unfortunately, the keypad button events are not recognized/seen when listening to lutron_event and the event entities are not updated. All other lutron actions appear to be fine but no lutron_events for keypad buttons.

In contrast, if I just add the line for HWI_SLIM keypad to the standard pylutron file, the keypad events are seen and the event entities are created and updated.

I would be happy to explore why the events are missing from the pylutron pull you are working on.

@rzulian
Copy link
Owner

rzulian commented May 7, 2024

@txwindsurfer you have to use this branch https://github.com/rzulian/pylutron/tree/homeworks-support
which already has the support for HWI_SLIM

@txwindsurfer
Copy link

@rzulian Yes that is the file I am using; I just didn't reference the branch in my post. It has the HWI_SLIM in it. However, I am not using the custom component but using the standard Lutron component to allow for a backwards compatibility check on this pylutron file. If backwards compatibility is not important, I can install the custom component and go from there.

This configuration is producing this error messages indicating confusion between PRESS and PRESSED :

`Logger: pylutron
Source: /usr/local/lib/python3.12/site-packages/pylutron/init.py:217
First occurred: 1:45:40 PM (1 occurrences)
Last logged: 1:45:40 PM

Uncaught exception
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 215, in run
self._main_loop()
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 206, in _main_loop
self._recv_cb(line.decode('ascii').rstrip())
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 568, in _recv
handled = obj.handle_update(args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 1193, in handle_update
return self._components[component].handle_update(action, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 1039, in handle_update
self._dispatch_event(ev_map[action], {})
File "/usr/local/lib/python3.12/site-packages/pylutron/init.py", line 707, in _dispatch_event
handler(self, context, event, params)
File "/usr/src/homeassistant/homeassistant/components/lutron/event.py", line 97, in handle_event
elif event == Button.Event.PRESSED:
^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Event' has no attribute 'PRESSED'. Did you mean: 'PRESS'?`

@ronluna
Copy link
Author

ronluna commented May 7, 2024

@txwindsurfer make sure that inside your custom_components folder there are no other folders (old or backup lutron folder) using the same domain (lutron) in the manifest.json file as this might override the required pylutron version and preventing the use of the pylutron library that you are attemping to use.

1- ssh to HA
2- access the HA docker containe with:

docker exec -it homeassistant /bin/bash

3-uninstall any pylutron library using:

pip3 uninstall pylutron

4- install the library in question with:

pip3 install git+https://github.com/rzulian/pylutron.git@homeworks-support#

5- Change to manifest.json file to reflect something like this:

{
  "domain": "lutron",
  "name": "Lutron by RZ",
  "codeowners": ["@cdheiser", "@wilburCForce"],
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/lutron",
  "iot_class": "local_polling",
  "loggers": ["pylutron"],
  "requirements": ["git+https://github.com/rzulian/pylutron.git@homeworks-support#pylutron==0.2.6"],
  "version": "v10.0.5"
}

6- Restart HA

@txwindsurfer
Copy link

@ronluna Excellent instructions. Thanks! This is a fresh install, so I don't have a custom components folder or any custom components installed.
2-accessed docker container, 3-removed pylutron library, 4-installed RZ's library and 5-modified the manifest.json file in /usr/src/homeassistant/homeassistant/components/lutron. and 6 Restarted HA.

Start-up indicated "Setting up Lutron by RZ" so that appears to have worked. Lights work. 4 scenes were added all referencing the same button on 4 different keypads so integration is seeing some of the HWI_SLIM keypads. However, not sure why only 4 scenes as I have multiple keypads with 10 buttons per keypad. However, still no recognition of lutron-events or event entities when I press a button with same error as before: 'Event' has no attribute 'PRESSED'. Did you mean: 'PRESS'?

@rzulian
Copy link
Owner

rzulian commented May 8, 2024

@txwindsurfer it looks like you are running the standard lutron integration. You have to change all files, not only the manifest.

@rzulian
Copy link
Owner

rzulian commented May 23, 2024

@ronluna I've a branch that is implementing the support for the sysvars.
You need to use https://github.com/rzulian/core/tree/ron-variables for the integration and https://github.com/rzulian/pylutron/tree/homeworks-support-sysvar for pylutron.
The list of variables' ids is hard coded in line 139 in the init.py

If you have time to test it and give me some feedback, then I can finalise it

@ronluna
Copy link
Author

ronluna commented May 23, 2024

@ronluna I've a branch that is implementing the support for the sysvars. You need to use https://github.com/rzulian/core/tree/ron-variables for the integration and https://github.com/rzulian/pylutron/tree/homeworks-support-sysvar for pylutron. The list of variables' ids is hard coded in line 139 in the init.py

If you have time to test it and give me some feedback, then I can finalise it

Hey @rzulian , thanks for the above... I'm starting testing so I've added some sysvar into a timeclock and set them to unaffected as shown in the screenshot. I can see the new lutron_data.xml stored in HA with the newly created timeclock and the IntergrationID for the sysvar in questions but after restarting HA and loading the new lutron component is not adding anything new to the devices/entities table. any ideas?

image

by the way, I also just noticed that pylutron is not detecting button press/double/hold events for Palladiom Keypads, seetouch is working fine. I had to add PALLADIOM_KEYPAD entry into the device's list in pylutron init.py line 334

I also just noticed whenever any of the sysvar changes value the logs show a warning

Logger: pylutron
Source: /root/pylutron-homeworks-support-sysvar-rz/pylutron/pylutron/__init__.py:590
First occurred: 10:49:59 AM (2 occurrences)
Last logged: 10:50:05 AM

Unknown id 114 (~SYSVAR,114,1,0)
Unknown id 208 (~SYSVAR,208,1,0)

@rzulian
Copy link
Owner

rzulian commented May 23, 2024

Did you add the ids for your variables in line 139?
lutron_variable_ids = [155, 158]
They are not autodiscovered

@ronluna
Copy link
Author

ronluna commented May 23, 2024

Did you add the ids for your variables in line 139? lutron_variable_ids = [155, 158] They are not autodiscovered

Totally miss that, I only check pylutron's init.py and since it didn't match what you mentioned above about line 139... I ignored it.

It's working now... after hardcoding the variable ids into custom component's init.py on line 139.
Thanks!

For a moment there I thought that the approach was to use the lutron_data.xml file to auto generate the variables so no harcoding was needed. This works as well although would be nice to be able to add it to the component's config flow. but I think once a config flow has been completed it does not allow to be edited (or at least I haven't been able to figure out how to re run it without deleting it and reinitialising it again).

@rzulian
Copy link
Owner

rzulian commented May 26, 2024

It should be possible to have some sort of refresh config flow. I'll work on this to add the ability to change variable ids in the config, and also to let the user switch from cached and not cached xml db.

@ronluna
Copy link
Author

ronluna commented Jun 6, 2024

@rzulian would it possible to add support to set the sysvar value from within HA ?

@rzulian
Copy link
Owner

rzulian commented Jun 6, 2024

This is the plan, but I have to invest some time to learn the HA workflow. Is the current implementation working fine?

@ronluna
Copy link
Author

ronluna commented Jun 6, 2024

@rzulian , yes the sensors have been created properly and its values are changing accordingly. The one thing missing is just the ability to change the sysvar values from within HA.

@ronluna
Copy link
Author

ronluna commented Aug 29, 2024

Hello @rzulian , I created two new repos based out of yours and mine where I did the following:
Pylutron:

HA Lutron Component:

The stop action for shades is working correctly but the _set_state I has not been able to properly test as I've been unable to find a way to properly add the HA action that would call the _set_state function . Wondering if you could share some pointers on how to properly achieve it?

@rzulian
Copy link
Owner

rzulian commented Sep 4, 2024

Hey, I can add the palladiom support to the repo
Regarding the cover I need to check.
Why do you need to add the code for the set_state. Isn't it working ?

@ronluna
Copy link
Author

ronluna commented Sep 4, 2024

I didn't see any function on the code that would allow to change the sysvar value from within HA into Lutron, So I thought that it has not been added... Currently the addon reports the value of a sysvar within a sensor in HA correctly but I didn't see a way to change the value from within HA into Lutron.

maybe I'm missing something ?

@rzulian
Copy link
Owner

rzulian commented Sep 5, 2024

You are right, it's not working. Let me work on this

@rzulian
Copy link
Owner

rzulian commented Sep 10, 2024

I'm thinking about the way to change the variable from HA.
Current implementation using a sensor entity doesn't allow to change the value back in Lutron.
Possible solutuons:

  • implement a service that you can call to change a variable.
  • use a select entity instead of the sensor entity. The problem is that you don't know how many possible values can have a variable. In my case usually only two. What's your use cases?

@ronluna
Copy link
Author

ronluna commented Sep 10, 2024

I think it would be great to implement a service to change the SYSVAR variables (Instead of using sensor entities). The possible values for each SYSVAR will have to be extracted from the lutron program so those values can be properly implemented in HA triggers and conditions.

My scenerio is different. I'm setting different values for each different button's actions (Press, Double Tap and Hold) but there could a a release action as well so it looks like the most value a variable might carry is a total of 4.

image

@clementx2006
Copy link

Ok, it's working.

I had to change line 125 on event.py to:

        #self.async_write_ha_state()
        self.schedule_update_ha_state()

As Home assistant 2024.5.1 does not like async_write_ha_state due to "unsafe thread writes." .

Thank you @ronluna - was scratching my head around the "uncaught exception"!

@clementx2006
Copy link

Good day @rzulian @ronluna - I know this open issue is about SYSVAR support (which I don't use in my setup), can I just ask if it is possible to make this custom component somehow HACS compatible? Every time the container is restarted now I re-copy the files into the lutron folder inside the container and restart the HA (but not the container) so no longer automated when the server reboots... :-( Thank you in advance!

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

No branches or pull requests

4 participants