1. Set up Restful API support in Home Assistant
Sample door operations [open, close, state]
\\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\apps.yaml
---
commander:
module: commander
class: RestfulAPI
|
Restart the appDaemon if this file is changed
HomeAssisant Dashboard => System => Addons => AppDaemon => Restart
\\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\commander.py
import appdaemon.plugins.hass.hassapi as hass
class RestfulAPI(hass.Hass):
def initialize(self):
self.log("RestfulAPI initialized")
self.register_endpoint(self.api_handler, "commander")
self.action = None # will be remembered as long as AppDaemon stays running
async def api_handler(self, args, rargs):
action = args.get("action", "").lower() #convert actions to lower case
self.log(f"received {action}")
if action != "doorquery": # will respond equally to DoorQuery or doorQuery
self.action = action
self.log(f"Action updated to: {self.action}")
else:
self.log(f"Query received. Returning stored action: {self.action}")
response = {
"request": action,
"state": self.action,
"message": "Response from RestfulAPI"
}
return response, 200
|
This file can be changed without a restart
http://192.168.1.59:5050/api/appdaemon/commander?action=closedoor
Result
request "closedoor"
state "closedoor"
message "Response from RestfulAPI"
|
HomeAssisant Dashboard => System => Addons => AppDaemon => Log tab
2025-05-29 12:58:07.881196 INFO AppDaemon: New app config: commander
2025-05-29 12:58:07.902175 INFO AppDaemon: Starting apps: {'commander'}
2025-05-29 12:58:07.913284 INFO AppDaemon: Calling initialize() for commander
2025-05-29 12:58:08.125547 INFO commander: RestfulAPI initialized
2025-05-29 12:58:08.132613 INFO AppDaemon: App initialization complete
2025-05-29 12:58:18.561479 INFO commander: received closedoor
2025-05-29 12:58:18.573935 INFO commander: Action updated to: closedoor
2025-05-29 12:58:18.575042 INFO AppDaemon: API Call to commander: status: 200 OK
|
http://192.168.1.59:5050/api/appdaemon/commander?action=DoorQuery
Result
request "doorquery"
state "closedoor"
message "Response from RestfulAPI"
|
HomeAssisant Dashboard => System => Addons => AppDaemon => Log tab
2025-05-29 13:02:15.373524 INFO commander: received doorquery
2025-05-29 13:02:15.383417 INFO commander: Query received. Returning stored action: closedoor
2025-05-29 13:02:15.384491 INFO AppDaemon: API Call to commander: status: 200 OK
|
Notes:
Replace "192.168.1.59" with your Home Assistant server IP
URL should be lower case but "action" values needn't be
Back to the top
|
2 - Sample commands to operate virtual Hall light
\\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\apps.yaml
---
hall_light:
module: hall_light
class: RestfulAPI
|
Restart the appDaemon if this file is changed
HomeAssisant Dashboard => System => Addons => AppDaemon => Restart
Create virtual device
HomeAssisant Dashboard => System => Devices & Services => Helpers tab
+ CREATE HELPER
Select Toggle
Enter hall_light as name
|
\\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\hall_light.py
import appdaemon.plugins.hass.hassapi as hass
class RestfulAPI(hass.Hass):
def initialize(self):
self.register_endpoint(self.api_handler, "hall_light")
async def api_handler(self, args, rargs):
action = args.get("action", "").lower() #convert actions to lower case
self.log(f"received {action}")
# Control or check the Hall light based on the command
if action == "turn_on_hall_light":
self.turn_on("input_boolean.hall_light")
response = {"message": "Hall light has been turned on."}
elif action == "turn_off_hall_light":
self.turn_off("input_boolean.hall_light")
response = {"message": "Hall light has been turned off."}
elif action == "check_hall_light":
light_status = await self.get_state("input_boolean.hall_light")
response = {"message": f"The hall light is currently: {light_status}."}
else:
response = {"message": "Unknown action."}
return response, 200
|
http://192.168.1.59:5050/api/appdaemon/hall_light?action=turn_on_hall_light
Result
{"message": "Hall light has been turned on."}
|
Notes:
Replace "192.168.1.59" with your Home Assistant server IP
URL should be lower case but "action" values needn't be
Back to the top
|
3. Implemented in the SimpleHome app

Device 5 =
DeviceName: Hall Light
DeviceIP: 192.168.1.59:5050
DeviceHTTP: HTTP
DeviceMake: HomeAssistant
DeviceMode: Off/On
DeviceDate: 2025-05-02
DeviceOff: api/appdaemon/hall_light?action=turn_off_hall_light
DeviceOn: api/appdaemon/hall_light?action=turn_on_hall_light
DeviceQuery: api/appdaemon/hall_light?action=check_hall_light
DeviceState1: off
DeviceState2: on |
Back to the top |
4 - Create functional commands to operate Sofa light
\\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\apps.yaml
---
lights:
module: lights
class: RestfulAPI
|
Restart the appDaemon if this file is changed
HomeAssisant Dashboard => System => Addons => AppDaemon => Restart
\192.168.1.59\addon_configs\a0d7b954_appdaemon\apps\light.py
import appdaemon.plugins.hass.hassapi as hass
class RestfulAPI(hass.Hass):
def initialize(self):
self.register_endpoint(self.api_handler, "lights")
async def api_handler(self, args, rargs):
action = args.get("action", "").lower() #convert actions to lower case
self.log(f"received {action}")
# Control or check the SSofa light based on the command
if action == "turn_on_sofa_light":
self.turn_on("switch.mystrom_sofa_light")
response = {"message": "Sofa light has been turned on."}
elif action == "turn_off_sofa_light":
self.turn_off("switch.mystrom_sofa_light")
response = {"message": "Sofa light has been turned off."}
elif action == "check_sofa_light":
light_status = await self.get_state("switch.mystrom_sofa_light")
response = {"message": f"The Sofa light is currently: {light_status}."}
else:
response = {"message": "Unknown action."}
return response, 200
|
http://192.168.1.59:5050/api/appdaemon/lights?action=turn_on_sofa_light
Result
{"message": "Sofa light has been turned on."}
|
192.168.1.59:5050/api/appdaemon/lights?action=turn_on_sofa_light
192.168.1.59:5050/api/appdaemon/lights?action=turn_off_sofa_light
192.168.1.59:5050/api/appdaemon/lights?action=check_sofa_light
Notes:
Replace "192.168.1.59" with your Home Assistant server IP
URL should be lower case but "action" values needn't be

SimpleHome request
|

SimpleHome result
|
evice 14 =
DeviceName: HA sofa light
DeviceIP: 192.168.1.59:5050
DeviceHTTP: HTTP
DeviceMake: HomeAssistant
DeviceMode: Off/On
DeviceDate: 2025-04-06
DeviceOff: api/appdaemon/lights?action=turn_off_Sofa_light
DeviceOn: api/appdaemon/lights?action=turn_on_Sofa_light
DeviceQuery: api/appdaemon/lights?action=Check_Sofa_light
DeviceState1: off
DeviceState2: on
|
Back to the top
|
5. Installation versions and usage
Raspberry Pi
HA Core 2025.5.2 HA Supervisor 2025.05.3 HA Operating System 15.2 HA Frontend 20250509.0 Appdaemon 0.17.0
Fitbit SimpleHome app V5.3.06
Usage:
URL examples can be used from anywhere. Such as:
your Fitbit watch.(with SimpleHome) or other application for other watches where the connected phone has access to the Home Assistant network
or shortcuts stored on any device, phone, tablet, PC, Mac on the same network
Be sure to use URLs in lower case but "action" values aren't case sensitive in theses examples
|
|