Appdaemon attributes not affecting lights

Hi there,

I’m having issues with AppDaemon not “actually” updating the attributes of my lights.
I have Kasa RGB lights which I can control no problem from automations, scenes or UI. Changing the state ON/OFF works fine, but changing brightness changes the value before being reset to its previous value.

My code is a bit messy to share all of it, but these are the core parts:

 self.entity = self.adapi.get_entity(entity_id, domain="hass")
 self.entity.set_state(state="on", attributes={"brightness": brightness})

The attribute brightness is updated and I can see that in the UI and in the state inspector, but soon after it reverts back to the original value.

Any suggestions?

set_state” only changes the internal value in Home Asssistant and does not communicate with actual devices, so the state and attributes returns to what your light entity is reporting to Home Assistant. You can use “turn_on`” or “call_service” in Appdaemon to communicate with devices.

self.call_service("light/turn_on", entity_id=entity_id, brightness=brightness)
1 Like

This corresponds to the “set state” (POST state) endpoint in HA’s API documented here

This endpoint sets the representation of a device within Home Assistant and will not communicate with the actual device. To communicate with the device, use the POST /api/services// endpoint

Let me jump in… What do I do if it is not a light?
In my case it is a alexa media player Device derived from an Amazon Echo Dot.
I also realized that “set_state” won’t change the volume or anything else.

I know there is an media_player service called “volume_set” but I am not able to figure out what it expects as parameters.

The yaml is

action: media_player.volume_set
metadata: {}
data:
  volume_level: 1
target:
  entity_id:
    - media_player.buro
    - media_player.cassian
    - media_player.wohnzimmer

So is there a way to find out what a service needs and how that nested parameter are handed over?
And what if I do not want to manipulate volume… the entity has plenty of parameters. I am a bit surprised that set_state is just HA internal and cannot imagine a usecase.
I feel HA lacks docu here and 99% of the users never touch the layer

Regards Marc