maximvelichko / pyvera

A python library to control devices via the Vera hub
GNU General Public License v2.0
26 stars 31 forks source link

Excluding Vera Scenes and Devices configuration #103

Closed htcheng closed 3 years ago

htcheng commented 5 years ago

Hi,

This thread I believe should be cross-linked here.

The reporter is correct that vera scene IDs and device IDs can share the same number - I was just about to ask whether there is an easy way to exclude all Vera Scenes and then add them in selectively like with other components, but it does not appear so and if I try to exclude scenes based on IDs as indicated above, I run into the same issue where the device and scene ID numbers overlap.

I've been running HA 0.82.1 and using the native Homekit support for everything except scenes for which I use the Homebrige plugin. Everything's been working great and reliably.

Vera Scene support for homekit was added in HA 0.83+ - but when I make the minor change of importing only 9 scenes from Vera, I am getting a strange error after about 1 hour in Home Assistant and Vera updates stop working (see below). Under HA 0.82.1 and earlier, I load the same vera devices and scenes, but do not get this error. I suspect it is because I have a LOT of Vera scenes that are configured within Vera for controlling IR components like stereo receivers, TVs, etc. This is why I was interested in excluding all scenes and then selectively adding the ones I want to use in HA -- and thus coming across this issue of device and scene ID conflicts.

Anyone have any suggestions or workarounds for 0.83+? Otherwise, I'll leave it running as is, but this is a must-have for my setup, so I'll need a longer-term solution as I'm stuck on 0.82.1.


Traceback (most recent call last): File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection raise err File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "/Users/default/.pyenv/versions/3.6.5/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/Users/default/.pyenv/versions/3.6.5/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Users/default/.pyenv/versions/3.6.5/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Users/default/.pyenv/versions/3.6.5/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/Users/default/.pyenv/versions/3.6.5/lib/python3.6/http/client.py", line 964, in send self.connect() File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connection.py", line 181, in connect conn = self._new_conn() File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x1131a1518>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/Users/default/Projects/homeassistant/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘[vera.localip]’, port=3480): Max retries exceeded with url: //data_request?output_format=json&DeviceNum=206&id=variableget&serviceId=urn%3Amica

During handling of the above exception, another exception occurred:

alanfischer commented 5 years ago

It should be fairly trivial to add an exclude_scenes configuration option to the vera component in HA. That would get around the ID overlap issue. I might have time this week to get an HA pull request in for that...

pavoni commented 5 years ago

@alanfischer got there before I did. If you take a look at the logic for excluding devices (eg https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/vera.py#L88) then it should be fairly easy to add an extra config variable to do the same for scenes.

htcheng commented 5 years ago

Upon further investigation, it appears that the connection errors I highlighted above were present before the upgrade to HA 0.83+ (I just didn't notice the errors earlier in the log files). The connection errors seem to start in most cases EXACTLY (to the second) 60min after homeassistant is started. I suspect that they might be related to the large number of scenes I have in my setup and the need to subscribe to all of these scenes in the updater.

Other than the log files spitting out errors on the connections, the only symptom I get on Home Assistant is that the state of Vera variables in HA no longer update (temperature of thermostats, dimmer settings, etc), but clicking on lights and changing things within Home Assistant and via Homekit still work via Vera.

The connection errors appear to be related to the large number of scenes that I have in Vera, but the broader issue may be related to how pyvera tracks and subscribes to state changes between Vera and HA as highlighted in this issue.

Apologies for not being more helpful as I haven't coded in a long, long time and I'm only now starting to get back into things and don't know python at all.... I will take a look at how to exclude the Vera scenes as mentioned above as that does look like something even I can do with my limited knowledge...

htcheng commented 5 years ago

UPDATE - The error above occurs when Vera does a LUUP engine reload (duh). I continue to have strange issues post-reload updating state changes and keeping Vera in sync with HA that I'm investigating, but these are related to my other thread on thermostats. I'll keep this open as a feature request for scene exclusion.

htcheng commented 5 years ago

I replaced get_complex_value with refresh_complex_value with my thermostat setpoints (see other thread) and that solved the post-reload state change update issues and it appears to keep Vera in sync with HA now. Set up has been running very reliably now and haven't needed to exclude my vera scenes... yet.

pavoni commented 3 years ago

Stale - so closing.