I have some troubles finding the right code for a template sensor to read the probabilty and precipitation from the foreast and can find any documentation for HAss to read from a nested sensor with a dynamic date as the identifier to match. Can someone point me in the right direction? Thanks!
This should always match todays date (if it exists)
{% set date = now().stftime('%Y-%m-%d') %}
{% set item = state_attr('sensor.xyz', 'forecast') | selectattr('datetime','eq', date) | first %}
{{ item.precipitation_probability if item else 'unknown' }}
Iāve been thinking about moving back but Iād need to make some new integrations. Appdaemon is great but I donāt know if itās needed anymore. It really depends on the automation I guess.
What do you mean with this? Sorry, I donāt understand.
Currently Iām still doing all automations in AppDaemon, however with all the new features (like global variables) that will get introduced in 0.115, I need to rethink this as some of these currently missing features were the reason to use AppDaemon in the first place. However, one of the main uses for AppDaemon for me is to learn Python, in the hope to contribute some code to HA one day.
I have a few appdeamon apps that could be replaced with a built in integration. Iāve just been too lazy to make them. Iāve got one on my list thatās a pretty high up WTH, so I might be doing this pretty soon.
You could probably add stuff now. Itās not that hard and you donāt need to know the core that well. The hardest part is knowing how to use the API. If you can learn appdeamon, you can build an integration.
I am trying to do something similar but seem to be missing something with the last part. I am trying to make a template sensor with just the āscoreā of my image_processing, and numbers only even when no value/attribute is defined so it is a chartable valueā¦ I cannot figure out how to get just the numeric value.
This is the raw attribute:
I have tried a few variations of this which gets me close but I cannot get it to pull the numeric value for score. I tried [0], [āscoreā] and a few others I found in some similar posts. I am not sure why it doesnāt like it, the extra curly braces? :
You say āthis is the raw attributeā, but if that is {{ state_attr('image_processing.doods_side_yard', 'score') }} I donāt see how youād get the result you pasted.
Note the warning box in this section ā always safer to follow its adviceā¦
Iām also not clear on what you mean by:
Are you saying that the match might be for something other than a person? Itās still solvable if that is the case, but will be a bit more involved. Try this in the template editor, and you can change person for anything else:
Excellent. So this template sensor should give 0 if thereās no detection, or the first non-zero score of however many scores exist:
template:
- sensor:
- name: Detection score
state: >-
{% set x = state_attr('image_processing.doods_side_yard', 'matches') %}
{% if not x %}
0
{% else %}
{% set ns = namespace(s=0) %}
{% for thing in x %}
{% if 'score' in x[thing][0] and ns.s == 0 %}
{% set ns.s = x[thing][0]['score'] %}
{% endif %}
{% endfor %}
{{ ns.s }}
{% endif %}
EDIT: updated in line with @petroās suggestion, which will also then give zero if the sensor doesnāt even have a matches attribute.