I have a problem if I passing the attributes in the set_state function.
For example: self.set_state("sensor.example", state=1)
it’s working as excepted.
but this is not working: self.set_state("sensor.example", state=1, attributes={"friendly_name": "Example sensor"}) the entity will be created without attributes.
The previous version works correctly: code-2022.3.x version
Interesting, first I am hearing of this issue. I am still on core-2022.3.8 myself. I will give this a try once I have a chance and see if I have the same issue.
Strange, could you please share your example with me? I tried again with 2022.4.4 and still not working, but I don’t know why. My appDaemon version is: 0.8.2
Sure… I am running AD from the dev branch which is version 4.2.2. The 0.8.2 add-on you are using should be using 4.2.0 but I am not aware of any changes that would cause an issue between those versions.
I have the following code in a test app.
import adbase
class Test(adbase.ADBase):
def initialize(self):
self.adapi = self.get_ad_api()
self.adapi.set_state("sensor.my_test_sensor2", state=1, attributes={"friendly_name": "My Test Sensor 2"})
When ran, I receive the following log messages.
2022-04-16 09:50:54.080431 INFO AppDaemon: Reloading Module: /conf/apps/test/test.py
2022-04-16 09:50:54.084943 INFO AppDaemon: Initializing app test using class Test from module test
2022-04-16 09:50:54.101901 WARNING test: test: Entity sensor.my_test_sensor2 not found in namespace default
2022-04-16 09:50:54.102649 DEBUG test: set state: sensor.my_test_sensor2, {'state': 1, 'attributes': {'friendly_name': 'My Test Sensor 2'}} from test
2022-04-16 09:50:54.102894 INFO AppDaemon: test: Entity sensor.my_test_sensor2 created in namespace: default
When looked at in HA dev tools, I see the following.