I am still breaking my mind on it.
I redo all the steps from the start.
Deleted Shelly for Hass
Reinstalled the script trough HACS
this is my configuration.yaml
python_script:
logger:
default: warning
logs:
homeassistant.components.python_script: debug
homeassistant.components.automation: info
then added this on 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'
mode: queued
max: 999
trigger:
- platform: homeassistant
event: start
- platform: time_pattern
hours: "/1"
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 }}'
In the shelly
enabled MQTT with right parameter clean session and retain checked MaxQoS 0
custom Mqtt prefix unflagged ( even if I should be able to change it right? )
flagged device discoverable
restarted HA
then in integration - MQTT mosquito broker - I can’t find any new discovered mqtt device but if I open mosquito log I can read that the shelly is correctly connected.
I manually launched Shellies Announce with the same results
If I run announce automation I can see this message in MQTT explorer
I deleted the HA log and restarted this is the new fresh log
2020-08-20 11:00:00 ERROR (MainThread) [homeassistant.components.automation.shellies_discovery] While executing automation automation.shellies_discovery
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in async_render
return compiled.render(kwargs).strip()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'payload_json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'dict object' has no attribute 'payload_json'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 430, in async_trigger
await self.action_script.async_run(variables, trigger_context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 802, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 563, in async_run
await super().async_run()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 183, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'dict object' has no attribute 'payload_json'
If I search for the shelly in entity I can only find it as device tracker
I really don’t understand what I am missing