I’ve got REST switches working half-way. What I mean is, they work great for the HomeBase but do not seem to work for the Indoor cams.
A functioning REST switch seem to require 3 parts:
- The sensor
- The rest_command
- The switch itself that draws from the sensor state and implements the rest_command
Sensor Sample:
sensor:
- platform: rest
name: Eufy Home Base Guard Mode
resource: "http://IP:PORT/getPlainValue/eufy-security.0.T8010XXXXXXXXXXX.station.guard_mode"
scan_interval: 10
value_template: >-
{% set v = value | replace('"', "")|int %}
{{ {0: "Away",
1: "Home",
2: "Schedule",
3: "Custom1",
4: "Custom2",
5: "Custom3",
47: "Geofence",
63: "Disarmed"}[v] | default("Unknown state:" + (value|urlencode)) }}
rest_command Sample: (I’ve only set it up for Home and Disarmed, the two features I use most. But you could set up rest_commands for all the modes identified in the sensor above)
rest_command:
eufy_home_base_guard_mode_home:
url: "http://IP:PORT/set/eufy-security.0.T8010XXXXXXXXXXX.station.guard_mode?value=1&ack=false"
eufy_home_base_guard_mode_disarmed:
url: "http://IP:PORT/set/eufy-security.0.T8010XXXXXXXXXXX.station.guard_mode?value=63&ack=false"
Switch Sample:
switch:
- platform: template
switches:
give_it_a_name_switch:
friendly_name: "Give It A Name Switch"
icon_template: hass:shield-home-outline
value_template: "{{ is_state('sensor.eufy_d_home_base_guard_mode', 'Home') }}"
turn_on:
service: rest_command.eufy_home_base_guard_mode_home
turn_off:
service: rest_command.eufy_home_base_guard_mode_disarmed
EDIT: Regarding the rest_commands working on HomeBase but not on indoor cameras. I think it’s possibly (v. likely!) an I.D.-10-T (idiot) error on my part. I thought both devices were configured the same, but they’re not: the HomeBase is on the main network and the indoor cameras are on an isolated IoT VLAN. This is a remote site that is connected to my home network (where I’m running HA and all this stuff) via a site-to-site OpenVPN connection. My home network xxx.xxx.1.xxx can see the remote network xxx.xxx.2.xxx but cannot see the remote IoT VLAN xxx.xxx.40.xxx. So as I see it, there are two possible ways to fix this: 1. get physical access to the remote indoor cameras and change them over to the xxx.xxx.2.xxx network so they can be seen by Home Assistant. Or 2, spin up a ioBroker docker container on the xxx.xxx.2.xxx network that can “see” the IoT VLAN xxx.xxx.40.xxx network and be seen by my HA instance running on xxx.xxx.1.xxx. I’ve wasted a lot of air time here on the HomeBase vs. Indoor cameras (SORRY!!), and I think it’s probably a dum-dum user mistake. Will report back after implementing either 1 or 2. If I’m correct in my assumption that this is the issue, the rest_commands
should be working great!
EDIT2: YEP. User error. Spun up a container on the 2.xxx network that can see the 40.xxx network, and I’m now able to change mode for the indoor cameras no problem. Just remapped my configuration.yml entries to the location of the 2.xxx container and good to go. Shoot, I’m sorry everyone for all the back and forth on the indoor cameras not working. They work fine using rest_commands.