Remote Commissioning
In this scenario the customer is sent the HEMS in the post and then commissioning is completed remotely by a technician with customer cooperation.
HEMS is plugged in to power and router (possibly before phone call).
HEMS connectivity is verified by technician.
Technician SSH into HEMS Host OS via Balena Cloud.
Customer connects EV charger / relay controller either to HEMS wifi or home wifi.
Technician determines IP of EV charger / relay controller.
Technican uses curl to configure devices in consultation with customer (see details below for settings).
Technician verifies configuration of devices using HA.
Technician configures PowerShaper service HA integration.
Provides any other support / help.
Determining IP/mDNS addresses of energy appliances
If they are connected to the HEMS wifi then you can unambiguosly determine from the lease table in the Host OS (assuming they are still connected):
cat /var/lib/NetworkManager/dnsmasq-wlan0.leases
Getting information about EV charger using curl
This can be useful for testing basic connectivity and responsiveness and determining serial number where it cannot be looked up in lease table.
curl "http://<IP address or mdns name of EV charger on network>/config"
Getting information about Shelly using curl
This can be useful for testing basic connectivity and responsiveness, testing to see if settings have been correctly applied, seeing what version of firmware is/if there is firmware update waiting to be installed, and obtaining serial in case not connected to HEMS wifi.
curl "http://<IP address or mdns name of ShellyEM on network>/status"
Commissioning EV charger using curl
The main step for commissioning the EV charger is configuring the MQTT connection. This can be done via curl in the following way:
curl "http://<IP address or mdns name>/savemqtt?enable=true&server=<IP address of HEMS on relevant network>&topic=openevse-YYYY"
Commissioning Shelly using curl
The Shelly can be connected to the HEMS MQTT server with the following commands:
curl http://10.42.0.xx/settings -G --data-urlencode "mqtt_server=10.42.0.1:1883"
curl http://10.42.0.xx/settings -G --data-urlencode "mqtt_enable=true"
(replacing xx with the correct value for the Shelly’s IP address)
The Shelly schedule and auto_off parameters can be set through the API. You can do this by sending the following calls from the Host OS:
curl http://10.42.0.xx/settings/relay/0 -G --data-urlencode "schedule_rules=0100-0123456-on,0600-0123456-off"
curl http://10.42.0.xx/settings/relay/0 -G --data-urlencode "schedule=true"
curl http://10.42.0.xx/settings/relay/0 -G --data-urlencode "auto_off=21600"
The current configuration can be retrieved with the call:
curl http://10.42.0.xx/settings/relay/0 -G"
Changing hostname online
Note that this should not normally be neccesarry as of October 2020 as the hostname should be set correctly in the image when the HEMS are created.
As per https://www.balena.io/docs/reference/supervisor/supervisor-api/#patch-v1devicehost-config the HEMS hostname can be modified online by making a request to the Balena supervisor API by getting a terminal either on the host or a running container with privileges:
curl -X PATCH --header "Content-Type:application/json" --data '{"network": {"hostname": "ccoop-hems-XXXX"}}' "$BALENA_SUPERVISOR_ADDRESS/v1/device/host-config?apikey=$BALENA_SUPERVISOR_API_KEY"
Modifying Home Assistant user/password
Can be useful in sitations where user has forgotten username/password after (re)setting it themself etc. Insider the HA container the hass command is available. This allows you to run a set of ‘embedded’ utility scripts (which are not documented but can be found here: https://github.com/home-assistant/core/tree/dev/homeassistant/scripts ):
hass --script <script name> <script args>
You might want to add -c /config (or similar) between <script name> and <script args>. For example:
hass --script auth -c /config change_password example_user A-Very-Strong-Password
A restart of homeassistant is required afterwards.
Deleting Home Assistant users/logins
All Home Assistant users/logins can be deleted without affecting the entities (apart from the area definitions) or recorded data using the procedure outlined here : https://www.home-assistant.io/docs/locked_out/ . However, in addition to the files listed there you also now need to delete the person and core.area_registry. So the full list of files that need to be deleted:
auth
auth_provider.homeassistant
onboarding
hassio
cloud
person
core.area_registry
In order for this to take effect the HA server first needs to be stopped, however stopping the server will result in the container restarting immediately! Instead, stop the BalenaOS HA service from the dashboard and then find the path of the mapped named docker volume for the /config/.storage folder on the Host OS. This can usually be found (tested on BalenaOS 2.51.1) on the Host OS in /mnt/data/docker/volumes/ .