Problems with Shelly Integration

Hey, I bascially have the same issue as described in not enough info for shelly integration · Issue #16978 · home-assistant/home-assistant.io · GitHub

So, when I try to add the Shelly integration, I’m being asked for a host. And while I have no clue what type of host to insert there when I’d like the devices to be auto-discovered, none of the tried inputs was accepted (HA host, HA IP, IP of a random shelly).

I also tried to add the integration by adding “shelly:” to configuration, with not having any effect, besides

homeassistant    | 2021-12-16 11:00:03 INFO (MainThread) [homeassistant.setup] Setting up shelly
homeassistant    | 2021-12-16 11:00:03 INFO (MainThread) [homeassistant.setup] Setup of domain shelly took 0.0 seconds

So my question is, what do I have to do when I’d like to have my shelly devices to be auto-discovered with their Device Names.

Thanks for your help!

Put he IP address of your Shelly device in the host field.

Also make sure your devices are set up correctly:

ColoT is set and IP doesn’t work. Plus I don’t understand why you have to enter the IP of a Shelly when what you want is auto-discovery?!

Okay, I added debug log level for aioshelly.coap and am spammed with the following message now:

2021-12-16 15:55:24 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114

172.16.200.1 should be the host in the network of home assistant’s docker container

I tried a couple of things:
setting the CoIoT IP to the internal docker IP of home assistant, also to the host’s IP adress. Both didn’t work.

Some output I got:

2021-12-16 16:21:23 DEBUG (MainThread) [aioshelly.coap] CoapMessage: ip=192.168.1.250, type=periodic(30), payload={'G': [[0, 9103, 0], [0, 1101, 0], [0, 2101, 0], [0, 2102, ''], [0, 2103, 0]]}
2021-12-16 16:21:23 DEBUG (MainThread) [aioshelly.coap] Calling CoAP message update for device 192.168.1.250
2021-12-16 16:21:24 DEBUG (MainThread) [aioshelly.block_device] aiohttp request: /settings (params=None)
2021-12-16 16:21:25 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:28 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:28 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:28 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:31 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:31 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:32 DEBUG (MainThread) [aioshelly.coap] Invalid Message from unknown host 172.16.200.1: Wrong type, 114
2021-12-16 16:21:33 WARNING (MainThread) [aioshelly.block_device] device 192.168.1.250 initialize error - TimeoutError()

Is the firmware of your device up to date?

What version of home assistant are you running?

What? Nowhere does it say to do that.

Well, I understand you have to enter Home Assistant’s IP as CoIoT IP, don’t you? Wouldn’t have thought that the internal docker IP could be that wrong after it didn’t work out with the host’s IP. So what am I supposed to do then?!

I gave it another shot (from the HA server logs):

2021-12-16 22:44:14 INFO (MainThread) [homeassistant.components.shelly.utils] Starting CoAP context with UDP port 5683
2021-12-16 22:44:14 DEBUG (MainThread) [aioshelly.coap] Socket initialized on port 5683
2021-12-16 22:44:14 DEBUG (MainThread) [aioshelly.coap] Adding device 192.168.1.238 to CoAP message subscriptions
2021-12-16 22:44:14 DEBUG (MainThread) [aioshelly.block_device] aiohttp request: /settings (params=None)
2021-12-16 22:44:17 DEBUG (MainThread) [aioshelly.block_device] aiohttp response: {'device': {'type': 'SHSW-1', 'mac': 'E8XXXXXXABF7', 'hostname': 'shelly1-E8XXXXXXABF7', 'num_outputs': 1}, 'wifi_ap': {'enabled': False, 'ssid': 'shelly1-E8XXXXXXABF7', 'key': ''}, 'wifi_sta': {'enabled': True, 'ssid': 'UXXXX 1', 'ipv4_method': 'dhcp', 'ip': None, 'gw': None, 'mask': None, 'dns': None}, 'wifi_sta1': {'enabled': False, 'ssid': None, 'ipv4_method': 'dhcp', 'ip': None, 'gw': None, 'mask': None, 'dns': None}, 'ap_roaming': {'enabled': False, 'threshold': -70}, 'mqtt': {'enable': False, 'server': '192.168.33.3:1883', 'user': '', 'id': 'shelly1-E8XXXXXXABF7', 'reconnect_timeout_max': 60.0, 'reconnect_timeout_min': 2.0, 'clean_session': True, 'keep_alive': 60, 'max_qos': 0, 'retain': False, 'update_period': 30}, 'coiot': {'enabled': True, 'update_period': 15, 'peer': '192.168.1.10:5683'}, 'sntp': {'server': 'time.google.com', 'enabled': True}, 'login': {'enabled': False, 'unprotected': False, 'username': 'admin'}, 'pin_code': 'XXXXXX', 'name': 'EG Esszimmer', 'fw': '20211109-124958/v1.11.7-g682a0db', 'factory_reset_from_switch': True, 'discoverable': True, 'build_info': {'build_id': '20211109-124958/v1.11.7-g682a0db', 'build_timestamp': '2021-11-09T12:49:58Z', 'build_version': '1.0'}, 'cloud': {'enabled': False, 'connected': False}, 'timezone': 'Europe/Berlin', 'lat': 48.999962, 'lng': 8.38471, 'tzautodetect': True, 'tz_utc_offset': 3600, 'tz_dst': False, 'tz_dst_auto': True, 'time': '22:44', 'unixtime': 1639691054, 'debug_enable': False, 'allow_cross_origin': False, 'ext_switch_enable': False, 'ext_switch_reverse': False, 'ext_switch': {'0': {'relay_num': -1}}, 'actions': {'active': False, 'names': ['btn_on_url', 'btn_off_url', 'longpush_url', 'shortpush_url', 'out_on_url', 'out_off_url', 'lp_on_url', 'lp_off_url', 'ext_temp_over_url', 'ext_temp_under_url', 'ext_temp_over_url', 'ext_temp_under_url', 'ext_temp_over_url', 'ext_temp_under_url', 'ext_hum_over_url', 'ext_hum_under_url']}, 'hwinfo': {'hw_revision': 'prod-191217', 'batch_id': 1}, 'mode': 'relay', 'longpush_time': 800, 'relays': [{'name': None, 'appliance_type': 'General', 'ison': True, 'has_timer': False, 'default_state': 'last', 'btn_type': 'edge', 'btn_reverse': 0, 'auto_on': 0.0, 'auto_off': 0.0, 'power': 0.0, 'schedule': False, 'schedule_rules': []}], 'ext_sensors': {}, 'ext_temperature': {}, 'ext_humidity': {}}
2021-12-16 22:44:17 DEBUG (MainThread) [aioshelly.block_device] aiohttp request: /status (params=None)

But although it looks quite complete I get a “Failed to connect” in the HA UI after I entered that IP :frowning:

HA version (container) is core-2021.12.2, Shelly is 20211109-124958/v1.11.7-g682a0db

Any helis appreciated!

P.S.: why do I have to enter an IP in HA auf all if there is something like auto-discovery?

<host_ip>:5683

Host is very unspecific. But if you mean the IP address of the docker host then it’s exactly what I did and which led to some valid looking log entries in HA’s log.

And still adding the shelly integration fails. And still I don’t know why I have to provide an IP address when adding that integration.

1 Like

The exposed IP address of home assitant that your router sees.

That’s what I did and which produced the outcome described above

Any news on this one?
I’m also seeing the timeout error when i try do add shelly rgbw2 over a vpn connection.

Hallo,

I have the same problem and trying to get help by Shelly assistance.
It is very frustrating.

Claudio

As a workaround, you can set the Shelly devices to MQTT via their app and configure them in HA (after getting an MQTT broker up and running, of course). Not ideal if you want plug-and-play — but long-term rock-solid and immune to changes in non-core integrations.

Example: the switch and one of the sensors for my Shelly 1PM immersion heater switch:

mqtt:
  switch:
    - name: "Immersion switch relay"
      unique_id: 31ba14ba-0c7a-4e2b-9621-92856965edfa
      command_topic: "shellies/shelly1pm-xxxxxx/relay/0/command"
      payload_on: "on"
      payload_off: "off"
      state_topic: "shellies/shelly1pm-xxxxxx/relay/0"
      state_on: "on"
      state_off: "off"
  sensor:
    - name: "Immersion switch power"
      unique_id: 44f6d6de-be45-4697-8ff9-882fae91c6a1
      state_topic: "shellies/shelly1pm-xxxxxx/relay/0/power"
      unit_of_measurement: "W"
      device_class: power

Hi Troon,

sorry for my late reply …I’m not confident with this forum and did not received notification for your message, even if this discussion is flagged as “Watching”.
In addition I have to experience HA more deeply before applying your solution, so, thanks for your help for now … I don’t think I’ll be able to write again anytime soon.

Claudio, thanks again

I eventually went with GitHub - StyraHem/ShellyForHASS: Shelly smart home platform for Home Assistant and am fine since then

1 Like