Currently shelly devices can be easily added when connected to the local network. Shelly devices outside your network but connect to the shelly could are currently not able to connect to Home assistant. This function should be added to HA core. (on Homey this is working well, but i preferer to use HA)
No it shouldn’t. Reject the cloud. Free your home.
It’s called home automation — not world automation.
Jokes aside: Install HA at the other location. Your use case seems to fall outside of the realm of home automation and the goals of HA.
It’s not really clear why you have this situation and why you need this solution.
True, issue is that the shelly device is not in my home…
Hehe, yes good point.
I’m using a shelly uni device to monitor the battery level from my boat. With this i can check if the solar panel can keep up the charging or if i need to go there to charge it on 230V. So the shelly device is outside my home (and HA is in my home), therefore the cloud integration would be very nice for me.
A generic solution to your problem would be to use a cloud-based MQTT broker. The Shelly can connect directly to it. If you already have an MQTT broker on your home network, you’ll need to bridge the MQTT brokers.
This is not a serious opinion. I need to connect to a Shelly device in a remote house far away. We definitely need the possibility to integrate with remote Shelly devices over cloud!!!
I agree, I also use Shelly Uni in a remote location for something else and the cloud integration surely is needed.
But you can, as my post explained. There’s nothing hacky about it either. It’s an elegant solution requiring no changes. Could you indicate why you don’t like this option? What would make direct integration with Shelly’s cloud better?
If you wanted to get really complicated with it all, you could connect the network on the boat to the home network via a VPN (zerotier for example) and achieve a site to site connection. Then you would be able to access the shelly device as if it were local and potentially anything else you allow too without having to use a cloud based mqtt service or expose your mqtt server to the world.
Hello,
You can expose your Shelly devices to the cloud via your Shelly account settings.
In your account options, you can generate a Cloud access key: this will give you a URL, such as Server: https://shelly-956-eu.shelly.cloud, and an access key. In the settings of the device you want to expose to the cloud, you can enable its cloud connection and find its “id”.
Then, in Home Assistant (HA), you integrate your devices into your .yaml configuration using command-line and Curl actions.
You can find the different Curl commands for Shelly here: Shelly Cloud API Rest
example:
- sensor:
name: power_measure
command: >
curl -X GET https://shelly-799-eu.shelly.cloud/device/status -d "id=yyyyy&auth_key=xxxxx"
value_template: "{{ value_json.data.device_status.emeters.0.power }}"
- switch:
name: switch_test
command_on: >
curl -X POST https://shelly-789-eu.shelly.cloud/device/relay/control -d "channel=0&turn=on&id=yyyyy&auth_key=xxxxx"
command_off: >
curl -X POST https://shelly-789-eu.shelly.cloud/device/relay/control -d "channel=0&turn=off&id=xxx&auth_key=yyyy"
command_state: >
curl -X GET https://shelly-125-eu.shelly.cloud/device/status -d "id=xxx&auth_key=yyy"
value_template: " {{ value_json.data.device_status.relays.0.ison }} "
icon: >
{% if value_json.data.device_status.relays.0.ison == true %} mdi:toggle-switch
{% else %} mdi:toggle-switch-off
{% endif %}
To recap for anyone reading it. There are at least two ways of connecting to remote Shelly devices:
- Via the MQTT broker. Either expose your Mosquitto one over the internet, or ZeroTier/Tailscale, and connect from Shelly to it, thus publishing MQTT status and listening for commands from anywhere.
- Via the Web API, for which you need to create an API key and then use wget/curl to execute commands or poll the data.
Obviously, the MQTT route is the cleanest and responsive one.
Thank you for this!
I’ve gotten all of this into my configuration.yaml, with my auth key and device id of course, but I keep running into a problem.
Invalid config for ‘switch’ at configuration.yaml, line 39: required key ‘platform’ not provided
I have tried to understand what it wants but I’m not getting it. I have tried to add an entry for platform with various values. ie: switch, light, shelly, none
I have no idea what it wants
Can you tell me what I need?
switch:
name: Upper Gate Open
command_on: >
curl -X POST https://shelly-6-eu.shelly.cloud/device/relay/control -d "channel=0&turn=on&auth_key=@@@@@&id=*****"
command_off: >
curl -X POST https://shelly-6-eu.shelly.cloud/device/relay/control -d "channel=0&turn=off&auth_key=@@@@@&id=*****"
command_state: >
curl -X POST https://shelly-6-eu.shelly.cloud/device/status -d "auth_key=@@@@@&id=*****"
value_template: " {{ value_json.data.device_status.relays.0.ison }} "
icon: >
{% if value_json.data.device_status.relays.0.ison == true %} mdi:toggle-switch
{% else %} mdi:toggle-switch-off
{% endif %}
OK, I didn’t see that in the example code, but I think I have it
EDIT:
Thanks for your help, in the end its my fat fingers and mispelling that caused me issues. Working now as expected.
command_line:
- switch:
name: Upper Gate Open
command_on: >
curl -X POST https://shelly-6-eu.shelly.cloud/device/relay/control -d "channel=0&turn=on&auth_key=@@@@&id=*****"
From the docs it says
To enable it, add the following lines to your configuration.yaml:
# Example configuration.yaml entry
command_line:
- switch:
name: Kitchen Light
command_on: switch_command on kitchen
command_off: switch_command off kitchen
Did I miss something still?
Good to see.
Given it worked as expected, I am not sure what you are asking? Is it an issue with the difference in the yaml indentation?
for me this works
value_template: “{{ value_json.data.device_status.meters.0.power }}”
I have been using Tuya devices and the cloud integation. I have bought Shellies and used Shelly’s cloud but it would ne very nice to automatically add those Shelies to HA.
I set up HiveMQ cloud-based MQTT broker. Shellies and HA successfully connected to HiveMQ but none of the Shellies were discovered by HA.