Ok, now I think I’m seeing a real issue. I might be slamming the ISY with REST calls because I can only get a sequence to work properly by inserting 1 second delays between calls. Here’s the action: part of the HA automation:
action:
- data:
entity_id: switch.kit_lights_scene (ISY scene with Insteon devices)
service: switch.turn_on
- data:
entity_id: switch.dnh_lights_scene (ISY scene with Insteon devices)
service: switch.turn_on
- data:
entity_id: switch.laundryrm_light_scene (ISY scene with Insteon devices)
service: switch.turn_on
- data:
entity_id: group.fr (HA group)
service: homeassistant.turn_on
The first two clauses are scenes from the ISY, and the third is a group that looks like this:
fr:
name: Family Room
entities:
- switch.fr_reading_light (HA Z-Wave switch)
- switch.fr_table_light (HA Z-Wave switch)
- light.fr_torchiere_lights (ISY KeypadLinc)
When I trigger the action at the top, I see lots of traffic to the ISY and most of the lights come on, but the last item (the torchiere lights) never come on. I can trigger the automation over and over again and I get the same results every time.
On the ISY, I get the following in the error log:
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36-5] 192.168.1.199:42164->80
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36]: GET-->/rest/nodes/47494/cmd/DON
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Socket error
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Closing socket w/failure
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36-5] 192.168.1.199:42172->80
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36]: GET-->/rest/nodes/36117/cmd/DON
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Socket error
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Closing socket w/failure
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36-5] 192.168.1.199:42174->80
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36]: GET-->/rest/nodes/20615/cmd/DON
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Socket error
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Closing socket w/failure
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36-5] 192.168.1.199:42176->80
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36]: GET-->/rest/nodes/3C%20EB%20EC%201
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Socket error
Wed 2019/02/27 08:53:58 PM System -170001 [HTTP:0-36] Closing socket w/failure
The last REST call is the one for the torchiere lights and I see no activity in the ISY activity monitor for it at all. The others all seem to work anyway, despite the failures. Here’s a snippet from the HA log with ISY994 debug turned on:
2019-02-27 21:09:46 INFO (MainThread) [homeassistant.helpers.script] Script Turn on lights garage open: Executing step call service
2019-02-27 21:09:46 INFO (SyncWorker_14) [homeassistant.components.isy994] ISY Request: http://192.168.1.218:80/rest/nodes/20615/cmd/DON
_50
_51
2019-02-27 21:09:46 INFO (SyncWorker_14) [homeassistant.components.isy994] ISY Response Recieved
2019-02-27 21:09:46 INFO (SyncWorker_14) [homeassistant.components.isy994] ISY turned on scene: 20615
2019-02-27 21:09:46 INFO (SyncWorker_0) [homeassistant.components.isy994] ISY Request: http://192.168.1.218:80/rest/nodes/3C%20EB%20EC%201/cmd/DON
_50
_51
_71[INST-TX-I1 ] 02 62 00 00 11 CF 11 00
_71[INST-ACK ] 02 62 00.00.11 CF 11 00 06 LTONRR (00)
2019-02-27 21:09:46 WARNING (SyncWorker_0) [homeassistant.components.isy994] Bad ISY Request: http://192.168.1.218:80/rest/nodes/3C%20EB%20EC%201/cmd/DON
2019-02-27 21:09:46 WARNING (SyncWorker_0) [homeassistant.components.isy994] ISY could not turn on node: 3C EB EC 1
2019-02-27 21:09:46 DEBUG (SyncWorker_0) [homeassistant.components.isy994.light] Unable to turn on light
_50
You can see the REST call for the problematic lights in the middle, the failure at the bottom, and no activity for that device in between.
Here’s what it looks like with a 1 second delay between each section of the action:
2019-02-27 21:13:30 INFO (SyncWorker_1) [homeassistant.components.isy994] ISY Request: http://192.168.1.218:80/rest/nodes/3C%20EB%20EC%201/cmd/DON
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.components.automation] Executing FR Reading Light Status
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script FR Reading Light Status: Running script
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script FR Reading Light Status: Executing step call service
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.components.automation] Executing Downstairs Lights On
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script Downstairs Lights On: Running script
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script Downstairs Lights On: Executing step call service
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script Downstairs Lights On: Executing step delay 0:00:03
2019-02-27 21:13:30 INFO (SyncWorker_15) [homeassistant.components.switch.command_line] Running command: curl -X GET http://[email protected]/rest/vars/set/2/64/1
2019-02-27 21:13:30 DEBUG (Thread-2) [homeassistant.components.isy994] ISY Update Received:
_71[INST-ACK ] 02 62 00.00.1D CF 11 00 06 LTONRR (00)
_51
_71[INST-TX-I1 ] 02 62 3C EB EC 0F 11 80
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.components.automation] Executing FR Table Lamp Status
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script FR Table Lamp Status: Running script
2019-02-27 21:13:30 INFO (MainThread) [homeassistant.helpers.script] Script FR Table Lamp Status: Executing step call service
2019-02-27 21:13:30 INFO (SyncWorker_14) [homeassistant.components.switch.command_line] Running command: curl -X GET http://[email protected]/rest/vars/set/2/65/1
_50
2019-02-27 21:13:30 INFO (SyncWorker_1) [homeassistant.components.isy994] ISY Response Recieved
2019-02-27 21:13:30 INFO (SyncWorker_1) [homeassistant.components.isy994] ISY turned on node: 3C EB EC 1
2019-02-27 21:13:30 INFO (SyncWorker_1) [homeassistant.components.isy994] ISY updated node: 3C EB EC 1
_71[INST-ACK ] 02 62 3C.EB.EC 0F 11 80 06 LTONRR (80)
_160120190227 21:13:35
2019-02-27 21:13:30 INFO (Thread-2) [homeassistant.components.isy994] ISY Updated Variable: 65
_13[VAR 2 65 ] 1
_160120190227 21:13:35
2019-02-27 21:13:30 INFO (Thread-2) [homeassistant.components.isy994] ISY Updated Variable: 64
_13[VAR 2 64 ] 1
_71[INST-SRX ] 02 50 3C.EB.EC 3D.95.02 2F 11 80 LTONRR (80)
_71ISY/PLM Group=0, Max Hops=3, Hops Left=3]]>
ST1283C EB EC 150%
2019-02-27 21:13:30 INFO (Thread-2) [homeassistant.components.isy994] ISY Updated Node: 3C EB EC 1
2019-02-27 21:13:30 INFO (Thread-2) [homeassistant.components.isy994] ISY Node Control Event: 3C EB EC 1 ST
_71[D2D EVENT ] Event [3C EB EC 1] [ST] [128] uom=100 prec=0
Much better. I have several node servers on the ISY that hammer the ISY with REST requests without seeing these socket errors, so I’m not entirely convinced that that’s the problem.
Has anyone seen anything like this?
Edit: I think that this is exactly the same issue: https://forum.universal-devices.com/topic/24970-need-help-to-interpret-the-isy-log/. Michel says that the ISY will explicitly not send and will fail a command if it thinks that the Insteon network is “overwhelmed”, so maybe we need to detect that and resend the command in PyISY, or in the ISY994 component? The latter knows that the command failed.
Edit: This modification to PyISY seems to help:
def request(self, url, retries=0, ok404=False):
if self.parent.log is not None:
self.parent.log.info('ISY Request: ' + url)
try:
r = requests.get(url, auth=(self._username, self._password),
timeout=10, verify=False)
except requests.ConnectionError as err:
self.parent.log.error('ISY Could not recieve response '
+ 'from device because of a network '
+ 'issue.')
return None
except requests.exceptions.Timeout:
self.parent.log.error('Timed out waiting for response from the '
+ 'ISY device.')
return None
if r.status_code == 200:
self.parent.log.info('ISY Response Recieved')
# remove unicode from string in python 2.7, 3.2,
# and 3.4 compatible way
xml = ''.join(char for char in r.text if ord(char) < 128)
return xml
elif r.status_code == 404 and ok404:
self.parent.log.info('ISY Response Recieved')
return ''
else:
self.parent.log.warning('Bad ISY Request: {} {}: retry #{}'.format(ur
r.status_code, retries))
# sleep for half a second
time.sleep(.5)
if retries < 3:
return self.request(url, retries+1, ok404=False)
else:
return None
Basically, add a 0.5s delay and retry, up to three. When I see a failure, I sometimes go through 2 retries before it finally succeeds. Increasing the delay would probably increase the chance of success. In the meantime, I’ll see if the PyISY dev has some thoughts, and I’m curious to hear from anyone here.