Shellies Discovery Script

Check list looks good. in debug log i Have:

2020-06-03 15:41:26 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:41:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shelly1-AABB9900=relay-0=light, ext-0=temperature, ext-1=temperature, ext-2=temperature, force_update_sensors=True, shelly1pm-aabb9911=ext-0=temperature, longpush_off_delay=False, force_update_sensors=True, shellyswitch-123409FF=relay-0=fan, relay-1=light, shellyswitch-123409cc=relay-1=fan, shellyswitch25-334455AA=mode=roller, shellyplug-s-CCBBCCAA=relay-0=light, force_update_sensors=True, shellyht-11AA00CCDD=force_update_sensors=True, shellyht-11AA00CCEE=powered=battery, shellyht-11AA00CCFF=powered=ac, shellyrgbw2-AA123FF32=mode=white, shellyrgbw2-AA123FF84=mode=rgbw, shellyem-BB23CC45=force_update_sensors=True, ignored_devices=['shelly1-DD0011', 'shellyem-EECC22']>
2020-06-03 15:41:27 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:41:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shelly1-AABB9900=relay-0=light, ext-0=temperature, ext-1=temperature, ext-2=temperature, force_update_sensors=True, shelly1pm-aabb9911=ext-0=temperature, longpush_off_delay=False, force_update_sensors=True, shellyswitch-123409FF=relay-0=fan, relay-1=light, shellyswitch-123409cc=relay-1=fan, shellyswitch25-334455AA=mode=roller, shellyplug-s-CCBBCCAA=relay-0=light, force_update_sensors=True, shellyht-11AA00CCDD=force_update_sensors=True, shellyht-11AA00CCEE=powered=battery, shellyht-11AA00CCFF=powered=ac, shellyrgbw2-AA123FF32=mode=white, shellyrgbw2-AA123FF84=mode=rgbw, shellyem-BB23CC45=force_update_sensors=True, ignored_devices=['shelly1-DD0011', 'shellyem-EECC22']>
2020-06-03 15:41:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:41:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shelly1-AABB9900=relay-0=light, ext-0=temperature, ext-1=temperature, ext-2=temperature, force_update_sensors=True, shelly1pm-aabb9911=ext-0=temperature, longpush_off_delay=False, force_update_sensors=True, shellyswitch-123409FF=relay-0=fan, relay-1=light, shellyswitch-123409cc=relay-1=fan, shellyswitch25-334455AA=mode=roller, shellyplug-s-CCBBCCAA=relay-0=light, force_update_sensors=True, shellyht-11AA00CCDD=force_update_sensors=True, shellyht-11AA00CCEE=powered=battery, shellyht-11AA00CCFF=powered=ac, shellyrgbw2-AA123FF32=mode=white, shellyrgbw2-AA123FF84=mode=rgbw, shellyem-BB23CC45=force_update_sensors=True, ignored_devices=['shelly1-DD0011', 'shellyem-EECC22']>
2020-06-03 15:41:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:41:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shelly1-AABB9900=relay-0=light, ext-0=temperature, ext-1=temperature, ext-2=temperature, force_update_sensors=True, shelly1pm-aabb9911=ext-0=temperature, longpush_off_delay=False, force_update_sensors=True, shellyswitch-123409FF=relay-0=fan, relay-1=light, shellyswitch-123409cc=relay-1=fan, shellyswitch25-334455AA=mode=roller, shellyplug-s-CCBBCCAA=relay-0=light, force_update_sensors=True, shellyht-11AA00CCDD=force_update_sensors=True, shellyht-11AA00CCEE=powered=battery, shellyht-11AA00CCFF=powered=ac, shellyrgbw2-AA123FF32=mode=white, shellyrgbw2-AA123FF84=mode=rgbw, shellyem-BB23CC45=force_update_sensors=True, ignored_devices=['shelly1-DD0011', 'shellyem-EECC22']>

Now I figured it out something and my new logs are:


2020-06-03 15:50:46 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:50:46 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:50:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:50:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:51:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:51:01 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:51:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:51:02 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>

I dont see them on HA

python_script debug is needed.

Ho can i get it? I enable homeassistant logs with

logger:
logs:
homeassistant.components.python_script: debug

what else?

So now should be debug information from the script in the log.

2020-06-03 15:50:46 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:50:46 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:50:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":false, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:50:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:51:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F7C7B","mac":"ECFABC6F7C7B","ip":"10.0.0.141","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:51:01 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F7C7B, mac=ECFABC6F7C7B, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>
2020-06-03 15:51:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on shellies/announce: b'{"id":"shellyrgbw2-6F8492","mac":"ECFABC6F8492","ip":"10.0.0.126","new_fw":true, "fw_ver":"20190822-083406/master@4148d2b7"}'
2020-06-03 15:51:02 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=id=shellyrgbw2-6F8492, mac=ECFABC6F8492, fw_ver=20190822-083406/master@4148d2b7, discovery_prefix=homeassistant, qos=2, shellyrgbw2-6F8492=mode=white, shellyrgbw2-6F7C7B=mode=white>

Are those enough?

Nope. Those are from HA, not from the script.

What I have to look for in the logs for script logs?

When everything works there will be something like that:

2020-06-01 02:04:17 DEBUG (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] Sending to MQTT broker: ...
2020-06-03 16:37:26 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.shellies_discovery. Unknown error for call_service at pos 1:
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/automation/__init__.py", line 375, in action
    await script_obj.async_run(variables, context)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 85, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1157, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 81, in python_script_service_handler
    execute_script(hass, call.service, call.data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 100, in execute_script
    execute(hass, filename, source, data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 112, in execute
    compiled = compile_restricted_exec(source, filename=filename)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/compile.py", line 96, in compile_restricted_exec
    policy=policy)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/compile.py", line 68, in _compile_restricted_mode
    policy_instance.visit(c_ast)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1426, in visit_Module
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 317, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1201, in visit_For
    return self.guard_iter(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 161, in guard_iter
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 317, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1028, in visit_Assign
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 326, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 857, in visit_Call
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 326, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 902, in visit_Attribute
    args=[node.value, ast.Str(node.attr)],
AttributeError: 'Attribute' object has no attribute 'value'
2020-06-03 16:37:26 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shellies_discovery, old_state=<state automation.shellies_discovery=on; last_triggered=2020-06-03T16:37:26.224439+02:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-03T16:30:02.781938+02:00>, new_state=<state automation.shellies_discovery=on; last_triggered=2020-06-03T16:37:26.279465+02:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-03T16:30:02.781938+02:00>>
2020-06-03 16:37:26 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1671792336] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'automation.shellies_discovery', 'old_state': <state automation.shellies_discovery=on; last_triggered=2020-06-03T16:37:26.224439+02:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-03T16:30:02.781938+02:00>, 'new_state': <state automation.shellies_discovery=on; last_triggered=2020-06-03T16:37:26.279465+02:00, id=shellies_discovery, friendly_name=Shellies Discovery @ 2020-06-03T16:30:02.781938+02:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2020, 6, 3, 14, 37, 26, 286809, tzinfo=<UTC>), 'context': {'id': '34a6770e19194a5ea71be8b73ec73b2c', 'user_id': None}}}

Can this help?

Are you sure you installed the script correctly?

Uhm I hope so. I created python_scripts folder in the folder wher configuration.yaml and other files are present. I putted python_scripts in my configuration.yaml file, i putted the shellies_discovery.py in the python_scripts folder and created the following automations:

- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  trigger:
    - platform: mqtt
      topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data_template:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      discovery_prefix: 'homeassistant'
      qos: 0
      shellyrgbw2-6F7C7B:
        mode: "white"
      shellyrgbw2-6F8492:
        mode: "white"

Am I missing something?

Try to run the script from Developer Tools -> Services and show me the log after that.

I got “call failed” error. Here the log

2020-06-03 17:19:10 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1905852176] Received {'type': 'call_service', 'domain': 'python_script', 'service': 'shellies_discovery', 'service_data': {}, 'id': 16}
2020-06-03 17:19:10 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=shellies_discovery, service_data=>
2020-06-03 17:19:11 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1905852176] Error handling message: {'type': 'call_service', 'domain': 'python_script', 'service': 'shellies_discovery', 'service_data': {}, 'id': 16}
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/decorators.py", line 17, in _handle_async_response
    await func(hass, connection, msg)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 147, in handle_call_service
    connection.context(msg))
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1157, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 81, in python_script_service_handler
    execute_script(hass, call.service, call.data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 100, in execute_script
    execute(hass, filename, source, data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/python_script/__init__.py", line 112, in execute
    compiled = compile_restricted_exec(source, filename=filename)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/compile.py", line 96, in compile_restricted_exec
    policy=policy)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/compile.py", line 68, in _compile_restricted_mode
    policy_instance.visit(c_ast)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1426, in visit_Module
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 317, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1201, in visit_For
    return self.guard_iter(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 161, in guard_iter
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 317, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 1028, in visit_Assign
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 326, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 857, in visit_Call
    node = self.node_contents_visit(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 535, in node_contents_visit
    return super(RestrictingNodeTransformer, self).generic_visit(node)
  File "/usr/lib/python3.7/ast.py", line 326, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/srv/homeassistant/lib/python3.7/site-packages/RestrictedPython/transformer.py", line 902, in visit_Attribute
    args=[node.value, ast.Str(node.attr)],
AttributeError: 'Attribute' object has no attribute 'value'
2020-06-03 17:19:11 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1905852176] Sending {'id': 16, 'type': 'result', 'success': False, 'error': {'code': 'unknown_error', 'message': 'Unknown error'}}

I think your shellies_discovery.py file is malformed.

Morning,

Been trying to get this to work, but my shelly H&T doesn’t seem to be discovered.

configuration.yaml:

mqtt:
  broker: 192.168.2.50
  username: homeassistant
  password: supersecret
  discovery: true
  discovery_prefix: homeassistant

python_script:    

And in my automations.yaml:

- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
  action:
    service: mqtt.publish
    data: 
      topic: shellies/command
      payload: announce

- id: 'shellies_discovery'
  alias: 'Shellies Discovery'
  trigger:
    - platform: mqtt
      topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data_template:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'

I suspect i need to add homeassistant/ to shellies/announce and shellies/command?

If you think about topics, the answer is no.

If you use the mqtt add-on, the username can’t be homeassistant !

Thanks both. I messed up vlans, so shelly couldn’t reach the broker, that is fixed now, and it’s working nicely :slight_smile:

@Bieniu enjoy the beer i send

1 Like

Thanks, cheers!