Comments (5)
Hi there - this is failing when trying to set the attributes piece - it's not clear from your code what is actually in there - can you explain a little further?
from appdaemon.
Sure, I changed the code a bit, but it's not much of a matter. The new attributes dict has a spot for friendly_name
and icon
, to expose it to the HASS API. Less work in the long run for my final product. :)
2017-02-04 11:15:05.752874 WARNING ------------------------------------------------------------
2017-02-04 11:15:05.753426 WARNING Unexpected error in worker for App presence_listener:
2017-02-04 11:15:05.754236 WARNING Worker Ags: {'type': 'event', 'kwargs': {}, 'event': 'internal_trigger_ishome', 'function': <bound method PresenceListener.person_is_home of <presence_listener.PresenceListener object at 0x708a9250>>, 'id': UUID('5feaadfb-ade3-4790-875c-8404c08d19ae'), 'data': {'mac': 'a1:11:1a:a1:11:1a', 'last_seen': '2017-02-04 11:15:05'}, 'name': 'presence_listener'}
2017-02-04 11:15:05.754639 WARNING ------------------------------------------------------------
2017-02-04 11:15:05.758652 WARNING Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 458, in worker
function(args["event"], data, args["kwargs"])
File "/home/homeassistant/.homeassistant/appdaemon/conf/apps/presence_listener.py", line 91, in person_is_home
attributes=json.dumps(attributes))
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appapi.py", line 185, in set_state
args["attributes"].update(kwargs["attributes"])
ValueError: dictionary update sequence element #0 has length 1; 2 is required
2017-02-04 11:15:05.759490 WARNING ------------------------------------------------------------
And the relevant bit of code is below.
user_name
is type str
last_seen
is type str
in the format %Y-%m-%d %H:%M:%S
mac
is type str
.. I've altered it above in the error, but the format is there for you to understand.
# build the attributes for set_state()
attributes = {
"user_name": self.users[mac]['friendly_name'],
"mac": mac,
"last_seen": last_seen,
"friendly_name": "Presence",
"icon": "mdi:home"
}
# expose this information to the front end, including the full object
self.set_state('binary_sensor.{}_presence'.format(self.users[mac]['friendly_name'].lower()),
state=self.users[mac]['location'],
attributes=json.dumps(attributes))
Let me know if you have more questions
- SN
from appdaemon.
I think the issue is you are converting the attributes into JSON - that is not required and is in fact positively harmful. Under the covers in AppDaemon, the attributes dictionary is merged with the state dictionary, then the whole thing is converted to JSON ahead of sending it to HA, so you don't need to worry about JSON at all, just Python constructs.
Can you try it without the JSON conversion and report back?
from appdaemon.
Something something over optimization .... I should trust you more. That solved it!
from appdaemon.
Hehe, glad you got it working :)_
from appdaemon.
Related Issues (20)
- after upgrade to 0.15.1 it stop afer few second HOT 2
- Script wiped out after upgrade to 15.0 / 15.2 HOT 3
- Not Starting in Home Assistant with Latest Update HOT 2
- What Have you done? HOT 5
- appdaemon folder emptied on Nov 16? HOT 3
- Render template seems to have problems with special characters
- Not start anymore HOT 1
- Allow apps.yaml path to be configured
- Documentation to point to new configuration location HOT 5
- Weirt example in `Choosing a Start Time`
- Issue logging DEBUG level log entries HOT 2
- Add support for service calls that return data such as todo/get_items HOT 3
- Logging (self.log) does not properly handle encoding of some non-English characters. HOT 1
- Schedy App/script not working after update Appdaemon add-on to 0.15.2
- Add ability to trigger a manual check_app_update or to set a custom interval (or: is utility_delay safe to change?)
- Throw an error / refuse to load if apps.yaml has a duplicate top-level key HOT 2
- Double reset_timer set execution time to first time set
- Python 3.12 support HOT 4
- Python package imports - "expert mode" HOT 1
- Warning about "secrtets" from apps where yaml is commented out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appdaemon.