Hey!
What is a good approach to setup devices manually, for example, I have a few Android tablets with Fully Kiosk Browser app’s with the HA dashboard.
My initial thought is something like this, where all the rest_commands
, switches
and sensors
are in the same file:
configuration.yaml
homeassistant:
packages: !include_dir_named integrations
./integrations/tablets/{generic,livingroom,office}
.yaml
rest_command:
tablet_generic_screen_on:
url: http://IPADDRESS/?cmd=screenOn&password=PASSWORD&type=json
method: POST
tablet_generic_screen_off:
url: http://IPADDRESS/?cmd=screenOff&password=PASSWORD&type=json
method: POST
switch:
- platform: template
switches:
test:
friendly_name: "Screen Generic"
unique_id: tablet_generic_screen
value_template: "{{ is_state('binary_sensor.tablet_generic_screen', 'on') }}"
turn_on:
service: rest_command.tablet_generic_screen_on
turn_off:
service: rest_command.tablet_generic_screen_off
sensor:
- platform: mqtt
name: "Fully Kiosk Generic Battery Level"
unique_id: tablet_generic_battery_level
state_topic: fully/deviceInfo/DEVICEID
value_template: "{{ value_json.batteryLevel }}"
device_class: battery
unit_of_measurement: "%"
icon: mdi:battery-30
template:
- trigger:
- id: "on"
platform: mqtt
topic: fully/event/screenOn/DEVICEID
- id: "off"
platform: mqtt
topic: fully/event/screenOff/DEVICEID
- id: "on"
platform: mqtt
topic: fully/deviceInfo/DEVICEID
payload: true
value_template: "{{ value_json.screenOn }}"
- id: "off"
platform: mqtt
topic: fully/deviceInfo/DEVICEID
payload: false
value_template: "{{ value_json.screenOn }}"
binary_sensor:
name: "Fully Kiosk Generic Screen"
unique_id: tablet_generic_screen
state: "{{ trigger.id }}"
Is this approach fine, or are there better ways to achieve things like this?
1 post - 1 participant