#templates-archived

1 messages · Page 65 of 1

humble mortar
#

HA is calling itself in this setup is that what you are asking?

lyric comet
#

Yes, do you expect that to work?

humble mortar
#

Yes it works

lyric comet
#

I thought you said it was timing out

humble mortar
#

But after he is done talking it causes the error.

#

He says "The back door was opened" then I see that error in HA logs.

lyric comet
#

It is probably a network loopback error so the data is getting in, butit can't send back to itself

humble mortar
#

Is there a method to handle that?

lyric comet
#

Not using Rest probably, why are you not simply using a bash command.

humble mortar
#

For which step? We were first trying to use command_line if that is what you are saying but it doesn't accept templating

humble mortar
#

"However, I don't see templates are supported at all there"

lyric comet
#

You can but you need to use a sensor and not an Automation if you make it a switch you can turn on the switch to trigger the text and then turn the switch off ready for next time.

#

I recommend reading all the documentation for all the different command line options.

#

Another option would be to add the text you want to the end of a file and then set your script to read the last line from that file to send to the speach process.

plain magnetBOT
#

@hybrid halo I converted your message into a file since it's above 15 lines :+1:

hybrid halo
#

Crazy! I have a shelly 1PM template above that doesn't work?

fickle sand
#

A light.turn_on service will not work on a switch entity. Use switch.turn_on instead

#

Vice versa for light.turn_off

hybrid halo
fickle sand
#

But now you're calling a light service on a switch

#

That makes no sense

hybrid halo
# fickle sand But now you're calling a **light** service on a switch

Grr.
I'm too furious.
I want to write that on the floor plan card I call (service_data: switch-${entity.state})!
When I look at the status, in dev tools, it says (switch: false) and I have it set, (device_class: outlet).
And I came up with the idea to make a template like I did for the dimming switches, which seemed to me like a light because of the dimming!

hybrid halo
#

This is when you want to squeeze more out of the devices than they are designed for. Shelly has a special input for the switch and in my opinion is the cause of the failure!

marsh cairn
#

You don't mean the switch (binary sensor) states for decoupled switches, do you?

fickle sand
#

Does the 1pm support dimming? Only dimmers do if I call correctly and those are represented as light entities in HA

fickle sand
#

So either way you are using the wrong service or the wrong entity

marsh cairn
#

Are you trying to make a template switch based on the same switch?

hybrid halo
humble mortar
fickle sand
lyric comet
#

So put all the commands in a bash script?

#

with a delay in the script.

#

Sorry I was replying to NonaSuomy.

hybrid halo
fickle sand
#

Could you please start explaining from the beginning? What do you try to achieve with the template switch? And what has that to do with the floorplan action?

marsh cairn
plain magnetBOT
#

The XY problem is asking about your attempted solution rather than your actual problem.

loud ridge
#

Can someone explain how to convert this to the new format? ```- platform: template
sensors:
number_lights_on:
friendly_name: "Count of lights on"
value_template: >-
{{ states.light
| selectattr('state', 'eq', 'on')
| list | count}}
icon_template: mdi:lightbulb-group

#

if I do this:```template:
sensors:
number_lights_on:
friendly_name: "Count of lights on"
value_template: >-
{{ states.light
| selectattr('state', 'eq', 'on')
| list | count}}
icon_template: mdi:lightbulb-group

fickle sand
#

Please look carefully to the documentation

template:
  - sensor:
      - name: number lights on
        state: > 
          {{ states.light
                  | selectattr('state', 'eq', 'on')
                  | list | count}}
        icon: mdi:lightbulb-group
plain magnetBOT
hybrid halo
fickle sand
#

So you want to set a class within the floorplan to the switch entities?

#

Like this?
directly form the floor plan documentation

- entities:
    - binary_sensor.kitchen
    - binary_sensor.laundry
  state_action:
    action: call-service
    service: floorplan.class_set
    service_data:
      class: '${(entity.state === "on") ? "motion-on" : "motion-off"}
hybrid halo
hybrid halo
loud ridge
fickle sand
#

did you tried this

  state_action:
    action: call-service
    service: floorplan.class_set
    service_data:
      class: '${(entity.state === "on") ? "switch-on" : "switch-off"}'

as service_data: switch-${entity.state} does not make sense at all, it expects a mapping with the key class not a service

loud ridge
#

My configuration.yaml: sensor: !include sensors.yaml mqtt: !include mqtt.yaml
sensors.yaml ```template:

  • sensor:
    • name: number_lights_on
      state: >
      {{ states.light
      | selectattr('state', 'eq', 'on')
      | list | count}}
      icon_template: mdi:lightbulb-group
  • sensor:
    • name: battery_status_kitchen
      state: >
      {{ "True" }}
Check configuration says: required key 'platform' not provided.
marsh cairn
#

You are mixing new and legacy template sensor style - and are including incorrect

loud ridge
mighty ledge
#

template is a separate integration, it does not go in sensor

#

icon_template is only available on sensor: 's template platform (old style). It's not available in the template integration (new style)

loud ridge
#

This was in the file before: ```- platform: template
sensors:
number_lights_on:
friendly_name: "Count of lights on"
value_template: >-
{{ states.light
| selectattr('state', 'eq', 'on')
| list | count}}
icon_template: mdi:lightbulb-group

  • platform: template
    sensors:
    battery_status_kitchen:
    friendly_name: "Battery Status Kitchen"
    value_template: >-
    {{ "True" }}
mighty ledge
#

only icon is available

#

Right, that's the old style

#

the new style is a separate integration

#

is there a reason you're changing this at all?

loud ridge
#

Because this is a new system and I am trying to learn the new and not garbage things with the old.

mighty ledge
#

ok, then you should try to understand the difference between platform: template and the template integration

#

platforms are old, the are the way of the old

#

everything now is separated into their integration

loud ridge
#

So, there is an include for template in the configuration file? And where do sensors go?

mighty ledge
#

e.g. you have (old style)

sensor:
- platform: template
  sensors:
  ....

new style

template:
- sensor:
  ...
loud ridge
mighty ledge
#

no, like I said above. They are in the template section of your configuration.yaml

#

you can make that a separate file or not

loud ridge
#

So the template section can't be split to a file and imported?

mighty ledge
#

it can

#

any section in configuration.yaml can be split into a separate file

plain magnetBOT
loud ridge
#

so in configuration.yaml: ```template: !include template.yaml

mighty ledge
#

you're missing the colon

loud ridge
#

what if I wanted to break templates into multiple files?

mighty ledge
#

My configuration has them split the best way IMO

loud ridge
#

Do you know why, when I paste into a vscode file it doubles the indents on each line?

hybrid halo
fickle sand
hybrid halo
hybrid halo
silent seal
#

Because you have a single ' at the beginning of the class data, and not at the end

#
service_data: 
  class: '${(entity.state === "on") ? "switch-on" :
  "switch-off"}'
fickle sand
#

Was just gonna suggest that

loud ridge
mighty ledge
#

the sensor section accepts platforms, which are old ways to set things up

mighty ledge
loud ridge
#

Output to where or what?

silent seal
#
service_data: 
  class: '${`switch-${entity.state}`}'
#

Like so.

hybrid halo
loud ridge
#

Also, why does templates.yaml need '- sensor:' and mqtt.yaml is ok with 'sensor' (i.e.in the first column)

mighty ledge
#

because they are separate integrations with separate requirements

loud ridge
mighty ledge
#

Yes

#

That's why chatgpt and all other AI suck at configuring HA

#

each one is different

loud ridge
#

As the state?

mighty ledge
loud ridge
#

Didn't catch that.

hybrid halo
#
                    - entities:
                        - switch.tm_vh
                        - switch.tm_mi
                        - switch.tm_sp
                        - switch.tm_na
                        - switch.tm_di
                        - switch.tm_ko
                      state_action:
                        action: call-service
                        service: floorplan.class_set
                        service_data:
                          class: '${(entity.state === "on") ? "switch-on" : "switch-off"}'                   
                      tap_action: false
``` And now it works. Thank you very much.
hybrid halo
loud ridge
#

Is there an example of a template switch in the new format not the old? This is obviously wrong:```- switch:
- name: tpl_switch
turn_on:
service: switch.toggle
data:
entity_id: input_boolean.sillyswitch
turn_off:
service: switch.toggle
data:
entity_id: input_boolean.sillyswitch

mighty ledge
#

Switch doesn’t have a new format

loud ridge
#

Can it live in the same template file?

mighty ledge
#

No

loud ridge
#

Where does it go then?

mighty ledge
#

In switch

loud ridge
#

So, some templates go in template.yaml, other templates go in switch.yaml.

mighty ledge
#

No, switch template platforms go in switch

loud ridge
#

Then what is Template Switch integration?

fickle sand
#

Nothing, doesn’t exist

mighty ledge
#

Its the switch template platform

loud ridge
mighty ledge
#

That’s the platform

#

Notice how the documents show it goes in the switch integration, with the designation platform: template?

loud ridge
#

I'm lost.

fickle sand
#

The text is something misleading though by calling it an integration 😅

mighty ledge
#

I don’t know why you’re trying to understand this. Just follow the documentation for the integration.

loud ridge
#

I set out to define an area. I defined an entity, it shows up in the area, but not on the card. That needs a switch that references the entity. But, iI'm lost in platforms and integrations, and whatever. And that's not even what I really want. I want to create a virtual something that I can put on a dashboard to be display the state of devices that aren't in this system yet, because I don't want to shutdown my old OH system and shutdown my automation while I learn HA and migrate my zwave network.

mighty ledge
#

Then just follow the documentation and stop making up yaml. The template integration shows you how to configure the entities it supplies. Template switch shows you how to integrate them, it’s separate.

#

Add a unique id to your entities to be able to put them in areas.

loud ridge
#

They have unique id's AFAIK.

mighty ledge
#

You haven’t posted a single configuration with unique_id yet

loud ridge
#

When did I post an entity?

mighty ledge
#

You’ve posted multiple template (virtual) entities without unique_ids

loud ridge
#

Those aren't the entities in the area. I just went to entites and defined them.

#

The entityID field says input_boolean.sillyswitch

#

Sorry, I went to Helpers and defined that.

mighty ledge
#

Notice the difference in the word unique_id and entity_id

#

I’m going for a run, good luck.

loud ridge
#

yah, thanks, enjoy the run.

marble jackal
#

and you didn't add a unique_id

#

But template switches are not changed to the new format yet, you can only use the legacy format for them

loud ridge
#

So, what I defined there goes into a file switch.yaml with unique_id: '0a7476cc-d6c1-40ba-8ae1-606518c3497f' added?

random temple
#

hi. I have dropdown i want to incorperate into a light template to control the effects (the dropdown being a list of the effects, and from there I have automations from changes to the dropdown....).
How can i do this?

silent seal
marble jackal
loud ridge
marble jackal
#

you can do that in the GUI

#

as long as you provided a unique_id

proud orbit
#

I'm trying to use the gui for exploring templates, with the goal of getting the friendly_name of one of these:

<template TemplateState(<state light.garage_driveway_lights=off; supported_color_modes=[<ColorMode.BRIGHTNESS: 'brightness'>], color_mode=None, brightness=None, friendly_name= Garage Driveway Lights, supported_features=32 @ 2024-01-24T14:07:33.774485-08:00>)>

I can get all the lights which are on, via one of the examples ( states.light | selectattr(... ) | list

But I can't list / get the friendly_name attribute/slot/variable thing. To me it seems that the only queriable/selectable item is that first attribute.
I've tried various selectors from the jinja.palletsprojects.com doc to no avail.

what concept am I missing here?

loud ridge
silent seal
#

Assuming you're iterating through a list, it'll be something like:

entities | map('state_attr', 'friendly_name') | list
loud ridge
proud orbit
silent seal
#

What's your whole template so far?

proud orbit
silent seal
#

I think you need to start with expand(states.light) instead of states.light, because otherwise you get a list of states instead of the actual entities

#

Why are you mapping the friendly name of the state though?

proud orbit
silent seal
#

What is your end goal?

proud orbit
silent seal
#

But as a template, this should do the trick:

#
{{ expand(states.light) | selectattr('state', 'eq', 'on') | map(attribute='name') | list }}
proud orbit
silent seal
#

The trick is knowing what you're dealing with. Are you already using the template editor in the developer tools inside HA?

proud orbit
inner mesa
#

um how does 'name' resolve values for something called 'friendly_name'
Yes, name will use friendly_name if it's defined

silent seal
#

Without | map(attribute='name') this reveals that I am working with a list of TemplateState. I can add a | first after the list to trim it down to just the first one and make it easier to read. But as you noted, it shows a friendly_name there. The answer is actually "I took a guess and got lucky", because I don't remember where/if I learnt that mapping a name gets you the friendly name

inner mesa
silent seal
#

That's the place, RobC saves my bacon once again 😛

proud orbit
proud orbit
silent seal
#

Yeah, referencing the docs for things like that definitely helps. It's also worth knowing that devices have different attributes to entities.

proud orbit
# silent seal Yeah, referencing the docs for things like that definitely helps. It's also wort...

I'm cool with docs. I just didn't really expect that a 'discovery' tool querying a state machine which returns data structures containing what look like member values in key:value pairs would have alternate ways to resolve the value from keys. via magical keys. and not the displayed keys.
I'll dork around with the other attributes on these things to see what happens.
@silent seal very helpful thanks, you too @inner mesa

strange geode
#

Hello,
I have an issue with variables not showing.
Followed the instructions, but unfortunately no success.
Any obvious errors?
Using: Notifications: Send a notification with android_notify

service: notify.android_notify
data:
  message: test
  data:
    fontsize: large
    position: top
    duration: 8
    transparency: 45%
    color: red
    interrupt: 0
    video:
      path: >-
        /config/www/nest/cam/camera_person.mp4
  title: Doorbell

``` It returns with the message on my tv and android app. but no video or picture.
silent seal
#

What's the full code of the automation?

plain magnetBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

strange geode
silent seal
#

The path at the top level looks broken. You have a video > path, which looks right, but the other one you had looked wrong

strange geode
silent seal
#

Well it can't send you a live stream file, the file isn't "finished". But it can send you a still and redirect you to the camera when you tap on the notification.

strange geode
#

Yeah but i dont want it to stream, i want to send the clip that ha generates.

#

The file is there, and "finished" i just dosent send it..

silent seal
#

A file stored in /www/file.jpg on-disk is represented by /local/file.jpg in the notification. Note the change of the local part of the path.

strange geode
#

so what if the file are stored in the config folde? "config\nest\event_media"

silent seal
#

No, the /config/www gets replaced with /local

strange geode
#

thx, but the path im looking for is: config\nest\event_media

#

would that be: local/nest/event_media

silent seal
#

Well then you can't share that file. If the file isn't in the www folder you can't send it to the device.

strange geode
#

okay then that might be my issue 🙂 Can i add that folder i whitelist to make it accessible

silent seal
#

No, you can only send the files in the www folder. You're not actually sending the file as an attachment to the device, you're sending a link to the file to the device, and that link needs to work, which requires it to be in the www folder. https://www.home-assistant.io/integrations/http/

strange geode
#

okay because nest intergation saves the file in config\nest\event_media and not in www folder..

silent seal
#

(Which were also mentioned in the companion app documents I linked 😉 )

strange geode
#

So when i call this path it work just fine with a picture, but not with a mp4 file, so the path shows me it works but somethine else. :
image:
path: /config/nest/event_media/cam/dorbell.png

But when i call this no video:
video:
path: /config/nest/event_media/cam/camera_person.mp4

silent seal
strange geode
#

android 🙂

#

Thank you so much for all your help so far..

plain magnetBOT
#

@olive cape I converted your message into a file since it's above 15 lines :+1:

olive cape
#

Yeah I'd actually prefer if you didn't bot lol

#

It works just fine if I manually specify entity ids, and the template works properly in the template dev tool section and an automation, but in set_rgb (using the one from turn_off also doesn't work)

inner mesa
#

if you're going to use a template for entity_id, it needs to be nested under data:

#

and data_template is years and years out of date

#

I also note that the error says lights->controller->set_rgbw->0->entity_id and you only have set_rgb, so I can't explain that

olive cape
inner mesa
#

yeah, that example should be updated

olive cape
#

Appreciate it

lethal bison
#

Trying to set up a single automation for all my timer.finished actions.
If I set the automation to trigger on all timers, what sort of variables are available for my logic to identify which timer triggered the automation?
Something like:

trigger:
  - platform: event
    event_type: timer.finished
  action:
    service: script.turn_on
    target:
      entity_id: '{{ trigger.device }}'
fickle sand
#

In your case you need the entity_id, so it would be trigger.entity_id

lethal bison
#

I looked at that, but didn't see anything for timer. I"m somewhat expecting it to be handled as an event

fickle sand
#

But a timer entity will not work with the script.turn_on service

haughty breach
lethal bison
#

That wasn't a valid yaml, I'm sorry. I just cobbled together something to help get the point across.

#

from the traces, it appears it should be trigger.event.data.entity_id, as you said. Let me try again with the correct event data variables

#

Excellent! this now works as expected

willow wing
#

Hey, can it be that binary_sensor dont have last_updated? he only show me the last changed date but i trigger it each 10 minutes

trigger:
  - platform: time_pattern
    minutes: /5
action:
  - service: calendar.get_events
    data:
      start_date_time: "{{ now() }}"
      end_date_time: "{{ now() + timedelta(minutes = 10) }}"
    target:
      entity_id:
        - calendar.xxxxx
        - calendar.feiertage
    response_variable: termine

binary_sensor:
  #Advanced Heating Control
  - name: Advanced Heating Control Kalender
    unique_id: advanced_heating_control_kalender
    icon: mdi:palm-tree
    state: >
      {{  
        ( termine['calendar.xxxxx'].events | regex_search('Urlaub', ignorecase=True) ) or 
        ( termine['calendar.xxxxx'].events | regex_search('Krank', ignorecase=True) ) or 
        ( termine['calendar.xxxxx'].events | regex_search('HomeOffice', ignorecase=True) ) or 
        ( termine['calendar.feiertage'].events | count > 0 ) 
      }}```
fickle sand
#

All the 4 conditions should end with | count > 0 to work correctly

willow wing
#

okay i change it, but the binary should be updated than, each time when the trigger runs right?

fickle sand
#

I do think the state machine really does need an explicit state change to update that

willow wing
#

hmm thats bad, you have any idea how i can solve this?

#

when i have overlayed events i have no trigger

mighty ledge
#

last_changed and last_updated exist on all state objects

fickle sand
#

You could add an attribute which specifies what condition is true at the last trigger

#

That forces an update in the state machine by some changed conditions

mighty ledge
#

I'm not sure why you'd want it to update, it's a binary sensor

willow wing
#

this sensor does not update when i have overlayed events, all time true

#

but i need a trigger to change a sequenz behind

willow wing
mighty ledge
#

I'm not following you. If you want the binary sensor to change state so you can trigger, you need to change your logic

willow wing
#

he does not change because it has sometimes overlayed events, so the state is always true in this moment

mighty ledge
#

Right, but that's what you need to change

#

if you have overlaying events, you should figure out which event you want to track

#

in your logic

#

Or separate them into 3 separate binary sensors

willow wing
#

Bas example is nice, i will try.
no idea how i can change it in a other way, only when i create more templates, and this i dont like 🙂

mighty ledge
#

what do you mean "this I dont like", it takes 2 seconds with your current setup

#
#Advanced Heating Control
trigger:
  - platform: time_pattern
    minutes: /5
action:
  - service: calendar.get_events
    data:
      start_date_time: "{{ now() }}"
      end_date_time: "{{ now() + timedelta(minutes = 10) }}"
    target:
      entity_id:
        - calendar.xxxxx
        - calendar.feiertage
    response_variable: termine

binary_sensor:
  #Advanced Heating Control
  - name: Advanced Heating Control Kalender
    unique_id: advanced_heating_control_kalender
    icon: mdi:palm-tree
    state: >
      {{  
        ( termine['calendar.xxxxx'].events | regex_search('Urlaub', ignorecase=True) ) or  
        ( termine['calendar.feiertage'].events | count > 0 ) 
      }}

  - name: Advanced Heating Control Kalender
    unique_id: advanced_heating_control_kalender
    icon: mdi:palm-tree
    state: >
      {{  
        ( termine['calendar.xxxxx'].events | regex_search('Krank', ignorecase=True) ) or  
        ( termine['calendar.feiertage'].events | count > 0 ) 
      }}

  - name: Advanced Heating Control Kalender
    unique_id: advanced_heating_control_kalender
    icon: mdi:palm-tree
    state: >
      {{  
        ( termine['calendar.xxxxx'].events | regex_search('HomeOffice', ignorecase=True) ) or  
        ( termine['calendar.feiertage'].events | count > 0 ) 
      }}
willow wing
#

but i need to edit the names right?

mighty ledge
#

Yah

#

and unique_id

willow wing
#

yeah, your completly right, but for noobs like me, many new entities make it hard to hold the overview.

#

maybe with time i change my mind :)^^

mighty ledge
#

You're going to have a worse time with a single entity

willow wing
#

hm okay, i will try, thanks bas and petro

wispy ridge
#

hello dear community,
I need your help.
I get the following error in my HA log:
(I'll include the error code below)

I have installed 3 template.sensors under Helper, but unfortunately I don't know exactly which one (or all three?) produces this error.

Can you help me locate and correct this error?

plain magnetBOT
#

@wispy ridge I converted your message into a file since it's above 15 lines :+1:

wispy ridge
#

Part2

#

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 693, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 561, in async_render
compiled = self._compiled or self._ensure_compiled(limited, strict, log_fn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 764, in _ensure_compiled
self.ensure_valid()
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 513, in ensure_valid
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TemplateSyntaxError: unexpected char '‘' at 9
.
.
.

mighty ledge
#

The error tells you which template

willow wing
#

maybe unexpected char '‘'?

mighty ledge
#

it is

#

you copied code from an unformatted code source

#

use ' instead of or

willow wing
#

petro one question again, i tried the trigger via service, he gives me now zero events but the binary_sensor don't goes to off, how i can now troubleshoot these?

#

can i test the binary somewhere?

#

on templates the response_variable is missing

mighty ledge
#

You can call the service in the service caller

#

then copy the contents from the service caller, which will be yaml.

#

Then you can paste the yaml into a yaml to json converter

#

then copy the json and put the contents in a response variable like so...

{% set termine = '
{"myjson":"value"}  <--- PUT JSON HERE
' | from_json
%}
willow wing
#

ahh okay thank you

mighty ledge
#

Then you can directly test the templates as is below that line

#

it's a pain in the ass

wispy ridge
# mighty ledge you copied code from an unformatted code source

many thanks for your response. The error can then only be narrowed down to a template.sensor because I only used these lines of code there. What's strange, however, is that the syntax is correct. I have now copied the following code:

{% set gas = states('input_number.gaszaehler_sensor') | float %}
{{ ((gas) * 1) | round(2) }}

mighty ledge
#

you're using quotes that are not avialable for use in templates

#

the quotes MUST BE " or ', no other quote style.

#

literally only those 2 quote styles are acceptable.

#

You're using and

#

notice how they have a fancy twist to them

#

that means, they are bad

#

if you're using a phone, you have to hold down the quote key to bring up a list of quote options and choose the correct one.

wispy ridge
#

Yes, the unusual use of the quotation mark cannot be recognized in the code I copied and pasted.

I'll just use it "

mighty ledge
wispy ridge
#

I use the keyboard and this symbol which is on the pound (#) key

#

'

wispy ridge
# mighty ledge

OK. I found it. it was an unused template card. The curved quotation mark was there.

Thank you!

slow vine
#

I am getting stuck parsing json in a template. I can get it in dev tools|templates supplying the json manually, but when I try to parse it "live" its not doing what I expect

I want to get the count of elements within an array, what this would do jq '.cars | length' where the array is named "cars"
Can this be done in a template?

mighty ledge
#

post the json

simple nexus
#

Are there any limitations in using the Helper UI to create a template vs the 'legacy' way?

inner mesa
#

You can't add triggers or actions

simple nexus
#

Ah okay, thanks

still plank
#

i am trying to turn off a set of lights with the entities coming from a template. if I try my service call in the services panel of developer tools, it works, but if i try the same call in an automation action i get errors (Error while executing automation automation.bp_test: must contain at least one of entity_id, device_id, area_id) and usually only one or two lights actually turn off..

service: light.turn_off
data: {}
target:
  entity_id: >-
   {{ expand(area_entities("Living Room")) | selectattr('domain',
                'eq', 'light') | map(attribute = 'entity_id') | list }}
plain magnetBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

silent seal
#

But you could also just do this:

#
service: light.turn_off
target:
  area_id: bedroom
#

Obviously with a different area id

plain magnetBOT
#

@still plank I converted your message into a file since it's above 15 lines :+1:

still plank
#

and i still don't get why it works in one place and not the other

inner mesa
#

Your template can be more efficient, but I don't see why it wouldn't work in an automation. The template could just be this:
{{ area_entities('Living Room')|select('match', 'light.')|list }}

marsh cairn
#

Maybe a missing space in front of the template?

#

The posted service call has 3 spaces

still plank
silent seal
#

But you likely still dont need to expand the area entities and re-map them

#

There are lots of example templates in this channel

still plank
#

i think it might actually be the blueprint which triggers the action - it's mode = restart and the state changes that fire the actions come in very fast

silent seal
#

That would probably be a problem, you might want it to be queued or single.

still plank
#

can i just edit a blueprint with studio code server? or does ha (re)download it?

#

seems you need to reload automations after. but changing it to queued has sorted my problem. thank you for your help all

final trellis
#

am using the following action from double-take

plain magnetBOT
#

@final trellis I converted your message into a file since it's above 15 lines :+1:

final trellis
loud ridge
#

How do I set the state of an input_boolean in the Developer tools> template editor? This is not doing it and I can't find an example.{%set 'input_boolean.driveway_lights_active' = 'on' %}
And, yes, I know I'm missing something obvious.

final trellis
#

@loud ridge what do you need?

silent seal
loud ridge
#

I actually know that...obviously it can be set, I can set it in the Dev>Services. I can't find what the service is called, how to call it from in a template.

#

Actually "know" is the wrong word, suspect is better.

silent seal
#

It's making a service call, called input_boolean.turn_on

final trellis
#

I think you can't set the state from a template. You need a service call

loud ridge
#

Can someone please show me what to type in the Dev tools>Template? I'm sure it is not as simple as {%input_boolean.turn_on%} This has no reference to the entity to turn on.

final trellis
#

you dont type anything there.

#

head to services and look for input_boolean turn on

loud ridge
#

So, I can't set the state of entities and devices from the template tool?

#

But, I can get the values of the same entity there.

atomic blade
#

Correct, or from templates in general

final trellis
#

get yes, set no ...

atomic blade
loud ridge
#

I guess I'm an idiot...I've read that, more than once.

atomic blade
#

No, it's a complicated topic, and especially if you've just started using HA

loud ridge
#

So, templates basically allow access or creation of information that be used in logic to take action on the information, but templates have no action capability.

slow vine
#

is there a way to test if a string is valid json in a template so that | from_json doesn't fail?

humble nova
#

Can someone please help me with this code? This code counts the lights that are on, it counts individual smart lights which I have no problem with but I also have multiple lights that aren’t smart that turn on with a single switch so it doesn’t give a true report of the amount of lights on. I would like to count the number of lights that are also on a single relay

template:

  • sensor:
    • name: "Total Lights Count Template"
      state: "{{ states.light | rejectattr('attributes.entity_id', 'defined') | selectattr('state', 'eq', 'on') | list | count }}"

Is this the right thread? Thanks.

inner mesa
#

So you just want to add some number to that?

humble nova
#

Yes, for specific relays. So at the moment a relay can turn on 4 lights and it would show as 1 light on because obviously HA doesn’t know those lights except for the switch that’s on. This light count is shown on a card on my dashboard.

lyric comet
#

You could set up a template sensor for each relay and set the value to the number of lights or zero when the reply is off and add that number to your light count. Just give them a name which you can filter on. The other option is to use template lights and use the relay to control them, but you would need to set one up for everyblub rather than simply adding the count.

#

Another option depending on the number of relays would be something like this. With an if for each relay.

{%- set count = states.light | rejectattr('attributes.entity_id', 'defined') | selectattr('state', 'eq', 'on') | list | count %}
{%- if states('sensor.relay') == 'on' %}
{%- set count = count + 4 %}
{%- endif %}
{{count}}
sturdy yarrow
#

I have made a template switch that does not work. I have a machine that has one sensor saying running or not running. And I have a button that is just "press" and it toggles the machine. I was hoping to make a button template that I can turn the machine on/off with automation ect. Can anyone see why this isn't working?

- platform: template
    switches:
      icemaker:
        friendly_name: "Isbitmaskin"
        unique_id: 21587211-7f99-4529-a2a4-6e34e1ce2da2
        value_template: "{{ is_state('binary_sensor.isbitmaskin_ismaskin_status', 'on') }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: button.isbitmaskin_isbitmaskin_avp
        turn_off:
          service: switch.turn_on
          target:
            entity_id: button.isbitmaskin_isbitmaskin_avp
fickle sand
#

Use the button.press service for button entities

#

Services are tied to a specific domain and will not work with other domains entities

sturdy yarrow
#

That worked like a charm! Thank you! 🙂

final trellis
#

I have setup a small face recognition automation which open a frontgate when a certain face is detected

#

it stops at the condition match = true

#

what I am doing wrong ?

#

kindly asking, please have a look

marble jackal
#

The attribute value is probably a boolean, and not a string. Remove the quotes around true

final trellis
#

double-take publish results to mqtt and mqtt create a sensor called sensor.double_take_makis

#

I've tried that it still stops there

#

so basically, what am trying to do is, to be sure that it is me (match = true & confidence > 95) and then open the door

#

it stops on the conditions

#

also, please note on my screenshot that there are two "match"

marble jackal
#

Did you already try my suggestion?

final trellis
#

yes i did

#

it stops on true

#

even though the conditions are met

mighty ledge
#

Ok, so the problem is you're looking at thee attributes via the states page

#

it does not show nested values, I can tell immediately that there is a dictionary named match with a nested key also named match

#

Notice how you have an empty match: above match: true?

final trellis
#

I thought so

#

correct!

mighty ledge
#

so the path would be `state_attr('blah', 'match').match

#

assuming match has a match

#

key

final trellis
#

so Petro (thank you - you always help me the last 5 years) what is the best way to open the door with a positive match ?

marble jackal
#

press on the entity id to see the full overview with indentation

#

only the top level attributes can be used directly in a state condition

mighty ledge
#

because of what thefes just said

final trellis
#

can you help me with it please?

mighty ledge
#

You still need to look at the shape of your object

#

looking at it more, it looks like it would be state_attr('sensor.double_take_makis', 'zones').match.match

final trellis
#

TheFes is right. there is indentation that you can't see on attributes column

marble jackal
#

press on the entity_id, scroll to the top of your screen, and copy the attributes

#

then paste that between code tags

plain magnetBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

#

@final trellis I converted your message into a file since it's above 15 lines :+1:

mighty ledge
#

Ok, nope, first one was correct

marble jackal
#

the confidence should also be checked using a template

mighty ledge
#
trigger:
- platform: template
  value_template: >
    {% set attr = state_attr('sensor.double_take_makis', 'match') %}
    {{ attr and attr.match }}
condition:
...
action:
...
final trellis
#

so TheFes match and confidence checked with template

#

trigger or condition ?

mighty ledge
#

if you want to add confidence...

marble jackal
#

and and attr.confidence > 95

final trellis
#

I think the best option is to leave the trigger as the author says

mighty ledge
#
trigger:
- platform: template
  value_template: >
    {% set attr = state_attr('sensor.double_take_makis', 'match') %}
    {{ attr and attr.match and attr.confidence > 95 }}
condition:
...
action:
...
final trellis
#

ohhhh, I see

#

so as a trigger?

mighty ledge
#

you can do it as a condition too

final trellis
#

the thing, petro, is that this sensor, stays up only for 30''
then it reports Unavailable

mighty ledge
#
trigger:
- platform: state
  entity_id: sensor.double_take_makis
condition:
- condition: template
  value_template: >
    {% set attr = trigger.to_state.attributes.match %}
    {{ attr and attr.match and attr.confidence > 95 }}
action:
...
mighty ledge
#

I'd go trigger route myself.

final trellis
#

ok this is perfect. Now i see it

#

but face recognition takes place on three cameras

#

I want only to run on frontgate

#

(we have this as a state and as an attrbute)

#

shall we use a template under condition ?

mighty ledge
#

You can just use a state condition, regular no template state condition

marble jackal
#

you can also add the state to the template trigger

final trellis
#

ok let me try it

marble jackal
#

or the attribute, doesn't really matter

final trellis
mighty ledge
#

a state condition

final trellis
#

ok here is the final code

plain magnetBOT
#

@final trellis I converted your message into a file since it's above 15 lines :+1:

final trellis
#

correct right ?

#

I am so happy

#

It does work

#

It does work and is very impressive

final trellis
#

thank you @petro, thank you @marble jackal

marble jackal
#

This will trigger on any state change, I thought you only wanted it to trigger on the frontgate camera?

#

I would say you should have kept your original trigger

#
  - platform: state
    entity_id:
      - sensor.double_take_makis
    to: frontgate
final trellis
#

it will trigger yes, but it will stop on condition

#

@marble jackal right?

marble jackal
#

oh wait, I missed that second condition

#

but why add a condition if you can tackle it in the trigger

final trellis
#

this is what @petro said

#

it doesn't make a difference

#

if it does, i will change it

#

what's your opinion?

#

TheFes, you confused me now - cause Petro said it's ok

marble jackal
#

It doesn't matter much, but I would say it's more efficient to only trigger when you want it to trigger

#

and not let it trigger on all state changes, and then check in a condition if it triggered on the right camera

final trellis
#
platform: state
entity_id:
  - sensor.double_take_makis
from: Unavailable
to: frontgate
#

so this says, that it will trigger on frontgate, when triggered. (the only minus is that it might also triggered with false matches)

#

Something like this TheFes?

karmic oar
#

I've got a restful sensor that I'm trying to get to fail gracefully. If the server is unresponsive, value_json is seemingly unknown or unavailable or undefined. This template doesn't seem to do anything: value_template: "{{ value_json.packs[0]['c1'] | replace('*','') if value_json not in ['unavailable', 'unknown', 'none'] else states('sensor.ldpp_p1c1') }}"

#

And I can't reference the value_json outside the sensor because it's a restful sensor

#

I really just want my entity to hold on to it's last known good state rather than every few seconds showing Unavailable for its state

fickle sand
# final trellis ``` platform: state entity_id: - sensor.double_take_makis from: Unavailable to...

That from: is not needed.
The difference between defining the to state in the trigger or in the condition part is that in the first one, it only triggers if the sensor corresponds to the correct camera and checks then the condition (e.q. less triggering, can improve performance/backend io).
Or the latter one that triggers on each state change before checking each condition (e.q more unneeded automation triggers)

final trellis
#

i understant that

#

please give me a minute to explain something important

#

when double-take detects a face it publishes to mqtt
the first time confidence is 80% so it will stopped by condition

the second time, it publishes again, but this time the confidence is 97%% (bingo)

will it trigger on the second time ??? because state is already "frontgate"
it might remain frontgate and mqtt publishes new attributes

#

so yes, I totally undestand what are you saying about performance etc etc, but the 1 million question is if it will fire the second time, if the state hasn't change??

#

???

fickle sand
#

No it won't, but you can also trigger on the match attribute leaving both to and from empty. This ensures it only triggers when the dict in that attribute includes a change

#

Although the method by petro is also sufficient as the impact on performance on a modern cpu will not be significant

final trellis
#

and remove the condition template ?

#

Petro's method worked from the first place

fickle sand
#

No leave the condition untouched, that filters for the needed values

final trellis
#

so i have no option

#

i have to leave trigger with no definiton for from and to

#

unless if there is something else. Maybe petro can assist please?

marble jackal
#

the template condition is needed, the state condition is not needed if you check on that in the trigger

final trellis
#

i think i will stick with this
because now I'm having second thoughts it will have impact to the performance

fickle sand
#

Just stay with what you have. I was initially commenting on the from you added in the trigger

final trellis
#

with 3 cameras and many people around the building

#

thank you guys - I really appreciate it!!

fickle sand
#

Performance is only impacted if you have 1000s of unoptimized triggers/conditions in other automations.

#

Any modern cpu could handle this

final trellis
#

and I'm so exciting - it works very nice

#

would you please take a moment and have a look on my 2nd question about calculating water consumption ??

#

I already answered to impact and said that I don't want a database and long term data.
just sum water flow to a input number sensor and then be able to use it to an automation

#

here is the water sensor I want to use

fickle sand
#

I do not see a 2nd question in this channel?

final trellis
#

I guess you are right 🙂

#

I post it to automations

marble jackal
#

trigger on that sensor changing from 0

#

then store the current total somewhere

#

when the sensor changes back to 0, calculate the difference between the total on that moment, and the total you stored

#

that's the water usage

final trellis
#

@TheFes the instat flow sensor is dynamic

#

it changes constanly based on the water pressure - consumption
how to store this

#

?

humble nova
#

Template-sensor

marble jackal
#

you only need it to determine if the shower started, and stopped (when it goes back to 0)

final trellis
#

how to sum it ?

fickle sand
final trellis
#

i dont have an automation yet cause i don't know how to start

#

TheFes said trigger to 0, ok I get this

#

but I can't understand how to sum the water

fickle sand
#

the consumption is eventually determined by:

{{states('sensor.total_liters')|float - states('input_number.shower')|float(0)}}
final trellis
#

ooooooooooooooo

#

you doing it from this sensor ?

fickle sand
final trellis
#

I thought will go through the instant water_flow

fickle sand
#

Yeah you need that as trigger as I explained above

marble jackal
#

your goal is to send a notification with the water usage right?

#

or do you also want to it in an entity state?

fickle sand
cerulean oyster
#

Hope, someone can point me what I'm doing wrong.
I'm using almost decluttering cards to prevent multiple times repeating the layout.
For a variable I have the following:

  - my-list:
      - item: one
      - item: two

Then further I will access the list items in a for-loop with

        {% for item in '[[my-list]]' %}
        - {{ item }} -
        {% endfor %}

The output is: "-[--[--m--y-----l--i--s--t--]--]-"
Seems it iterates over the string, but not substitutes the variable.

marble jackal
cerulean oyster
#

It has also something to do with templates, that's why I asked here

marble jackal
#

there are no jinja templates used in decluttering card, it's a subject for #frontend-archived

#

and you can't template yaml like that

final trellis
#

TheFes would you be kind and have a look please?

#

for input number, to get just the number, I must template it ? or it can be done with other way?

#

?

final trellis
#

I want your opinion for the following wind template

plain magnetBOT
#

@final trellis I converted your message into a file since it's above 15 lines :+1:

final trellis
#

what do you think?

marble jackal
#

I'll have a look later, dinner time here, and need to put the kids in bed after that

final trellis
#

yes me too

slow vine
#

whats the right (working) way to do this:
{{get_info_response | default('{cars: [{car_id:{}}]}')|from_json}}
I am trying to not get this error:
UndefinedError: 'dict object' has no attribute when is not the expected output.

mighty ledge
#

post all your code and the error

pale idol
#
{% set t = value.split('\r\n')[3] | float(0) %}
{% if t = 0 %} 0
{% else %} 5.5*t*1.5
{% endif %}```

This is my above value template, the error I'm getting is `line 8: invalid template (TemplateSyntaxError: expected token 'end of statement block', got '=') for dictionary value 'value_template', got "{% set t = value.split('\\r\\n')[3] | float(0) %} {% if t = 0 %} 0 {% else %} 5.5*t*1.5 {% endif %}\n"`
#

line 8 corresponds to the value_template: > line

inner mesa
#

You have = where you need ==

mighty ledge
#

tbh, you don't need the if statement

#

5.5 * 0 * 1.5 is still 0

pale idol
#

sorry, that should be 5.5+t*1.5

#

the == always gets me

mighty ledge
#

you're also going to need {{ around your equation }}

slow vine
#

post all your code and the error

pale idol
#

so value_template: > {% set t = value.split('\r\n')[3] | float(0) %} {% if t == 0 %} 0 {% else %} {{ 5.5+t*1.5 }} {% endif %}

mighty ledge
#

indent your template

pale idol
#

already done, the formatting here on discord doesn't carry it over with my clipboard

#

the next question is how to get that particular entity to show up in a universal media entity as a slider on the ui

#

i've already got it in the attribute as volume_level and declared its unit_of_measurement as "%"

mighty ledge
#

No idea what you’re asking here

pale idol
#

so that value template belongs to a tcp command I have to send to an extron media switcher. The value template gets the volume level for a particular output

mighty ledge
#

That needs to have a volume that goes from 0 to 1

pale idol
#

ah, so take my else statement and divide by 100

mighty ledge
#

Well, double check what I said

#

Historically that attribute is 0 to 1 based

pale idol
#

right, the documentation doesn't specify a format it should be in.

mighty ledge
#

I still don’t know what you mean by sidebar

pale idol
#

on my denon avr media card, i've got mute, volume up, and volume down, followed by a slider

#

i wonder if it needs both volume_level AND volume_set

mighty ledge
#

It will

#

For the slider

pale idol
#

gotcha. well back into the code we go

eager yarrow
#

Heya, been sent here from the front door, they told me this is where the nerds hang around. 😉
I need to evaluate a value incoming from modbus, before it is finally appearing within an entity.
So I wonder if this is possible within the same entity that holds the value of the modbus register.
Is there any possibility to use state_attr() or similar for the 'own' value of an entity (if yes: how to reference it), or do I always have to put the evaluation into another entity?
Example - I would like to avoid the extra 'outsidetemp_final' entity, just work with 'outsidetemp' to keep it as compact as possible, as there will be hundreds of such modbus items:

#
outsidetemp:
# here all that is needed to get a register value from modbus

outsidetemp_final:
  value_template: >-
    {% if states('sensor.outsidetemp') | float == 3276.7 %}
      # 7FFFh - sensor is 'off', replace with 0 for charts
      0
    {% elif states('sensor.outsidetemp') | float > 3276.7 %}
      # below ZERO, INT16 to Signed INT
      {{ states('sensor.outsidetemp')  | float - 6553.6 }}
    {% else %}
      # all good, go ahead with sensor reading
      {{ states('sensor.outsidetemp') }}
    {% endif %}
#

(quite new to this, installed my first HA 2 days ago)

inner mesa
#

first, states are always strings, so things like {{ states('sensor.outsidetemp') - 6553.6 }} won't work. You need {{ states('sensor.outsidetemp')|float - 6553.6 }}

#

like you did earlier 🙂

eager yarrow
#

ooops, over looked that one - thanks 🙂

lyric comet
#

I would tend to set a variable for the outside temp, to save looking it up 3 times. If you need to define lots of these don't forget you can set up a template macro.

#

{% set temp = states('sensor.outsidetemp') | float %}

eager yarrow
#

I managed to read out the first registers in HA already; next step is to deal with what I've read.

lyric comet
#

I am not familiar with Modbus, so don't know what you need to get in and work with. I assume you are using the Modbus integration to work with this? Sorry to not be more help.

eager yarrow
#

Yeah, using the standard Modbus implementation of Modbus. Got the first temperatures already in HA, that's not the point:

plain magnetBOT
#

@eager yarrow I converted your message into a file since it's above 15 lines :+1:

eager yarrow
#

This is how it's displayed so far:

#

ooops, no pic pasting, I see

#

What I need to do is post-processing after reading.

lyric comet
#

What about
{{ now().strftime("%m%d") > "1121" or now().strftime("%m%d") < "0109" }}

pale idol
#

what is the best practice for sending a variable number over tcp or telnet? ideally i'd have something like service: telnet.send or tcp.send and put all the date in the data: value under it

lyric comet
# eager yarrow What I need to do is post-processing after reading.

Tom, do you need all the values all the time, if not if you only need them in automations you could use the Variable definition to compute them when you need them. Probably depends on if you want to track the refined values. Another "hack" could be to create a custom Integration based on the main one and use that to convert before the sensors are created.

eager yarrow
#

Most people using my plugin have 50...70 variables (~25 out of that are the same for all of them). Therefore my aim is to have it as flexible as possible.
A few have 150-200 variables.
I'm trying to get as close as possible to my old plugin and visu - see screenshot here. Not sure if I can get close to that in HA, though - we will see. 😉

pale idol
#

@lyric comet I've seen that thread before. I'm just not sure the best practice to get a value_template into the command_on line

#

or if thats even possible

lyric comet
#

There is an example in the thread. Sending TCP is a very outdated way to communicate, I assume what you are talking to is ancient.

pale idol
#

unfortunately so, its either tcp or telnet

#

or scraping the html

lyric comet
pale idol
#

i've kinda thought about that too. its pretty simple.

#

"01*$VARV" is all I have to send, where $VAR is some number 0-64

#

converting 0-64 to 0..1 is easy

#

and the volume_set function already provides 0..1

#

i'd really prefer not writing an integration for this thing.

lyric comet
#

Zombie, you should be able to use the command line options as discussed in the Thread. One of the experts might be around in a while to help.

eager yarrow
pale idol
#

@lyric comet I'm not sure the command line options are available in the container

next pasture
#

can somebody explain me why following code returns True
{% if states('sensor.worktime') | is_number -%} True {% endif %}
but this code returns TypeError: '>' not supported between instances of 'str' and 'int'
{% if states('sensor.worktime') > 0 -%} True {% endif %}

mighty ledge
#

states are strings

inner mesa
#

{{ "5"|is_number }} -> True

next pasture
#

lol, that's weird

inner mesa
#

just sayin'

#

it's how it was designed, and it's purpose

#

"can it be parsed as a number?"

lyric comet
next pasture
mighty ledge
#

macros only return strings

#

Jinja is not meant to output anything other than a string. Any thing else you see w/ HA and templates returning "types" is all handled after the template is resolved.

#

if you use {{ }} anywhere, it's returning a string

#

that's just how Jinja works.

next pasture
#

thanks.. that explains a lot

final trellis
#

@marble jackal regarding the shower automation I have an error on option 2

#

Error while executing automation automation.shower_test: Error rendering data template: Result is not a Dictionary

mighty ledge
#

post your data template

#

ya did something wrong

final trellis
#
service: input_number.set_value
target:
  entity_id: input_number.last_shower_water_consumption
data: |
  {{ usage | round(0) }}
mighty ledge
#

that's not returing a dictionary, that's returning a single value

#

you forgot value:

final trellis
#

that is what it says

#

wowwwwwwwwwwwww

#
service: input_number.set_value
target:
  entity_id: input_number.last_shower_water_consumption
data: 
  value: |
    {{ usage | round(0) }}
lyric comet
#

You did not like my answer then.

grim geyser
#

Hello everyone. Im trying to change this template to round to 0 decimals but havnt been able to get it to work. Is there a way? ${states['sensor.master_bedroom_broadlink_temperature'].state}°C

inner mesa
grim geyser
#

ok thanks

distant abyss
#

what would be the way to have a template select the state of the sensor one hour ago?

inner mesa
#

It's not possible

distant abyss
#

makes sense why i couldn't find anything

#

I have a binary sensor template and alert.yaml for my freezer, and I have the alert give me current temp,

#

but was curious if every hour it could tell me if the temp is going down

inner mesa
#

You'd need to use an SQL sensor to query the database

distant abyss
#

thats to much work, I think I can remember if the freezer is getting colder again

inner mesa
#

Look at a trend sensor

distant abyss
#

yea

lucid thicket
#

Or derivative

distant abyss
#

basement_freezer_temp: name: "Basement Freezer Temp" entity_id: binary_sensor.freezer_temp state: "on" # Optional, 'on' is the default value repeat: 60 can_acknowledge: false skip_first: true message: "Its getting hot in here: But I am a freezer you fucking idiot. Current freezer temp is {{ states('sensor.inkbird_freezer_thermostat_temperature') }} " done_message: "ICE ICE BABY!: The freezer is back below zero" notifiers: - mobile_app_andrew_phone - mobile_app_jessica

#

Alert.yaml is AWESOME btw

#

(have a binary_sensor template that trigger if above zero)

#

Its so rare it happens, and like today when it happened. I left the door open, I closed it. So I "knew" it was getting closer, but thank you

#

Second question, similarly, there is no way to make the weather entity a binary_sensor "Will it rain tomorrow"

#

"Will it rain today" Will it cloudy today? or is that possible?

plain magnetBOT
#

@modest isle I converted your message into a file since it's above 15 lines :+1:

lofty mason
#

@modest isle - I think what you're probably missing is unit_of_measurement
However that value template looks strange, maybe it should be {{value_json.Elevation}} ?

#

Sensors generally need a unit to be plottable as a numeric graph. Otherwise they get the timeline style graph.

modest isle
#

@lofty mason that could be it! I’ll have to mess with the unit_of_measurements option.
As for the value template, I changed it to your suggestion and seems to work the same - elevation is graphed in a “sensor card” yet flow rate is only displayed as the latest value in an “entity card”. How would I format the value_template to track both flow rate and elevation?

lofty mason
#

A sensor can only have one state (which is graphed). Attributes are more like seconary information, and you can't directly graph it.

#

You would want to create multiple sensors if you want multiple pieces of information.

#

You can either make 3 command_line sensors, or maybe better a single command line sensor with 3 attributes (as you currently have), and then additionally 3 template sensors, one for each attribute, so you can graph them.

final trellis
#

Good morning

#

Now I found you, would you please help me correct the following error?

marble jackal
#

What are you trying to calculate there?

#

Can you share the complete config in which that template is used

narrow surge
#

How can I fix this error: expected float for dictionary value @ data['value'] in:

service: input_number.set_value 
entity_id: input_number.home_solar_energy_total_production_last_value 
data_template: 
  value: "{{ trigger.to_state.state }} | float"

Value of the sensor (sensor.home_solar_energy_total): 30750.1

final trellis
#

the only reference in my files is platform time_date

marble jackal
marble jackal
final trellis
#

nope - no such entry

#

I removed this integration

#

I found it

#

it was a part of an automation

#

and it is part of a blueprint

#

line 122

marble jackal
#

It doesn't guard enough against unwanted states

#

It just isn't a correct template

#

"none" should be none

#

But a lot of other improvements could be made

narrow surge
marble jackal
#

Yep, it should be inside the curly brackets

karmic oar
#

I've got a restful sensor that I'm trying to get to fail gracefully. If the server is unresponsive, value_json is seemingly unknown or unavailable or undefined. This template doesn't seem to do anything: value_template: "{{ value_json.packs[0]['c1'] | replace('*','') if value_json not in ['unavailable', 'unknown', 'none'] else states('sensor.ldpp_p1c1') }}"
And I can't reference the value_json outside the sensor because it's a restful sensor
I really just want my entity to hold on to it's last known good state rather than every few seconds showing Unavailable for its state

distant abyss
inner mesa
#

You can get the previous and current value of an entity in an automation when the state changes

distant abyss
#

including alert.yaml ?

lucid thicket
karmic oar
#

That does not work. That’s what I had initially but it didn’t do anything.

lucid thicket
#

then you probably need to create a template sensor based off your rest sensor

#

why don't you try value_template: "{{ 1 }}" and see if that still becomes unavailable when the server is unresponsive

karmic oar
#

Interesting. What would that tell me?

lucid thicket
#

if it remains 1 then it confirms that the template still renders when the server is unavailable. My bet is that it still becomes unavailable, which means there is nothing you can do inside the value_template to avoid the sensor being unavailable

karmic oar
#

I would say that it does not. I can see value_json is undefined and trying to reference the associated values nested fails because they don’t exist in that moment

#

It’s like there needs to be a way to say “if there isn’t valid json this time, just reference the last value and try again later”

lucid thicket
karmic oar
#

That’s what the template tester says

#

I’m not at my computer at the moment

lucid thicket
#

the template tool will definitely say that if you don't define value_json

inner mesa
final trellis
#

so Petro, the automation worked yesterday. Today it was stopped by condition

loud ridge
#

I have mqtt sensors that send humidity. Unfortunately, some send, for example, 12% others send 12. What is the right way to deal with this? Some sort of template for the payload entry in the sensor definition? Basically looking for what to search for.

lucid thicket
# karmic oar I would say that it does not. I can see value_json is undefined and trying to re...

I just ran a couple tests:

  • I used http://www.google.com as the URL, which doesn't return valid JSON. I used the template {{ value_json is defined }} and the sensor state was false. Therefore the template rendered and the variable value_json was not defined
  • I did the same as above but used http://date.jsontest.com as the URL. The sensor returned true as expected
  • I did the same as above but used a non-existent URL http://jsontestx.com. The sensor disappeared, and the following error was logged:

Platform rest not ready yet: [Errno -2] Name does not resolve; Retrying in background in 30 seconds

I'm not sure how to replicate the problem you are seeing.

final trellis
#

@mighty ledge because you propose it here is the condition

condition: template
value_template: >-
  {% set attr = trigger.to_state.attributes.match %} {{ attr and attr.match and
  attr.confidence > 95 }}
#

would you please take a moment and have a second look?

#

match was true and confidence was almost 100%. So why it was stopped???

modern sluice
#

Hi, I struggle with templates and I couldn't find an example template for what I'm looking for. In webcore, it was easy to conditionalize an automation if a script has ran in the last X mins/hours. Can somebody help me craft a template that will let me conditionalize an automation if a script has ran in the last 5 mins please? I thought I saw this in the docs before but I couldn't find it.

final trellis
#

kindly asking, any one can have a look please?

inner mesa
#

I suggest that you review the "Changed Variables" section as shown here:

#

see if the values match what you think they are

marble jackal
#

You can download it in the top right corner

final trellis
#

all conditions met, but it was stoppped

#

so?

marble jackal
#

"confidence": 86.17,

#

Confidence was not above 95

#

So not all conditions were met

final trellis
#

pls hold

#

can you please convert this time for me ?

#

the one on json file

#

so i check with double-take data?

#

the timestamp is not the same

#

on this, confidence is pretty high

#

(99,48%)

#

what is the time stamp please?

#

oooooooooooooo

marble jackal
#

It could be that it detected two people and that the state didn't change

#

Enable the condition, and remove the to and for from the trigger

#

That version was better after all 🙂

final trellis
#

I figure it out

#

it didnt trigger at all!!

#

the screenshot was from 18.07 but json was for a previous trigger at 4

marble jackal
#

And why didn't it trigger?

#

The json is from the same moment

#

I guess your timezone is GMT +2..

#

Which would make the json from 18:07:08, which is the same time as your screenshot

final trellis
#

but see the screenshot

#

the one i sent with the state attributes, confidence was 99%

#

so it can't be the same

marble jackal
#

I already explained a possibly cause for that. If it did two matches on the same camera after each other, and the first one is below 95% it won't trigger a second time, because the state doesn't change

#

I mentioned two people there, but it could also be a second match on the same person

final trellis
#

got you

#

So i will leave the trigger as it was at the first place and add condition for the camera..

lucid thicket
tame axle
#

Correct me if i'm missing the channel, but i'm trying to offset some thermometers, found something on the forum but don't quite get it
https://community.home-assistant.io/t/adding-offset-to-sensor-data/20382/5?u=cristianmihai
Is the first bit(starting with homeassistant:) supposed to go into configuration.yaml ?
And..where should i put the second code block? it looks a bit like the config for ESPhome, with the pin defined and everything, however i don't think that's where it should go

lucid thicket
#

is this an ESPhome device, and do you want to take care of the offset in the ESP device itself?

tame axle
#

it is ESPhome, i don't quite care where i take care of the offset as long as i can get a working value

lucid thicket
#

personally I would do it on the device itself, but it's up to you. You can't change the sensor in home assistant, but you can create a new sensor in home assistant with the corrected value. That is why I would recommend doing it on the device itself

tame axle
#

on the device it is

      filters:
      - offset: -4.0

found this, not sure it will work but gonna try

lucid thicket
#

if you need help with your esp device config they have their own discord server, or you can try in #diy-archived

tame axle
#

got it. thanks!

modern sluice
final trellis
#

i need help with a template trigger:
if last day of month trigger at 23.55 else trigger at 00:10

torn meteor
#

this was a pain. Alexa Media has a string object array, and i needed a nested value:

{%- set json_string = states.sensor.library_dot_next_timer.attributes.sorted_active|from_json() -%}
{%- set data = namespace(vars=[]) -%}
{%- for item in json_string -%}
  {%- for key, value in item[1].items() -%}
    {%- if key == "version" -%}
      {%- set data.vars = data.vars + [value|int] -%}
    {%- endif -%}
  {%- endfor -%}
{%- endfor -%}

{{ data.vars|first|default(0) }}
#

probably a better way but this gets around updating a variable from in a loop

final trellis
#

anyone?

#

I was thinking something like

{{ 
(now().strftime("%d") | int) == states('sensor.days_in_current_month') 
and 
states('sensor.time') == "23:55" 
}}
#

as trigger

plain magnetBOT
#

@final trellis I converted your message into a file since it's above 15 lines :+1:

final trellis
#

can someone confirm pls this is ok ?

plain magnetBOT
#

@lament maple I converted your message into a file since it's above 15 lines :+1:

lucid thicket
# final trellis can someone confirm pls this is ok ?

You have a sensor that tells you the number of days in the current month? And another sensor that has the time in 24hr format with only hours and minutes? If that is all true, then you are just missing the filter to convert of the number of days sensor from a string into an int

#

You could do the template without those sensors, but if you have them you might as well use them. I’d say it’s also generally a bad idea to do an == comparison using time but at least in your case it will be true for a full minute. It’s better to use >= or <=

#

You can also use now().day instead of using strftime() and converting to an int

haughty breach
# final trellis can someone confirm pls this is ok ?

The follow clause will not work:
(now().strftime("%d") | int) == states('sensor.days_in_current_month')

States are always strings... you can't compare an integer to a string. Remove the int filter:
now().strftime("%d") == states('sensor.days_in_current_month')

marble jackal
#

@final trellis did you could also do all this without the need for additional sensors

- platform: template
  value_template: >
    {{
      (now() + timedelta(days=1)).day == 1 
      and now().strftime('%H:%M') ==  '23:55'
    }}
- platform: template
  value_template: >
    {{
      now().day != 1 
      and now().strftime('%H:%M') ==  '00:10'
    }}
#

Your 00:10 trigger should also trigger on the last day of the month, and not on the first day of the month

#

You could combine the triggers above in one trigger, when you combine them with or (and add some additional parenthesis)

final trellis
#

What i need is the following

#

all days of month trigger at 00.10
but the last day of month trigger at 23.55

#

am using the extra sensor to determine the last day and then do the comparison

marble jackal
#

If all triggers should be roughly 24 hours apart, you want to trigger twice on the last day of the month (at 00:10 and 23:55) and not at 00:10 on the first day of the month (that would have only have 15 minutes difference with the previous trigger)

final trellis
#

last day must trigger before 0.00.

marble jackal
#

Yes, I get that

final trellis
#

i have utility meters and they will reset. i want to avoid the extra helper

marble jackal
#

You know the utility meters store the previous period in an attribute right?

final trellis
#

so i guess your implementation is wrong

final trellis
sweet summit
#

How would I get a list of just the entities exposed to a specific voice assistant from a template?

marble jackal
#

That's not possible using Jinja templates

sweet summit
#

Appreciate the reply, thanks. Is there a way to put all exposed entities in a group (the old style domain agnostic groups) without manually copying them all to yaml each time? - I am working on a daily briefing script for a local LLM, and am trying to feed it a list of states for analysis

marble jackal
sweet summit
#

This looks interesting - thank you for your help.

final trellis
#

can someone explain how the following works??
{{ "{} {} Celsius.. {}".format(rm1, states("sensor.temperature_outdoor"),
rm2) }}

inner mesa
#

you're providing a format string with {} as placeholders for the parameters that you pass to format()

final trellis
#

what that it means ?

#

it does work - but why ?

inner mesa
#

what is confusing?

#

I told you what it does 🤷

#

it's a template

final trellis
#

you're providing a format string with {} as placeholders for the parameters that you pass to format()

inner mesa
#

yes, that's what I said

final trellis
#

is there any documentation for this please? I use it in one automation, works but it was n't mine

inner mesa
#

that's clear

#

there are three links in the channel topic that explain Jinja templates

#

Jinja uses Python objects and supports the methods on those objects

final trellis
#

ohhhhh it uses empty placeholders?

inner mesa
#

that just means that it fills them in the order you provide to format()

#

you can play with this in devtools -> Templates and see what happens

final trellis
#

i got it now

terse scarab
#

Is there anything specific template in HA for converting seconds, e.g. 37,800 Seconds = 10h 30m ?

#

Managed to add my clothes dryer but it reports in seconds. Got to fix that. 😛

marble jackal
alpine idol
#

Hi, I´m using the rest platform and then a template

device_class: temperature
unit_of_measurement: "°C"
value_template: '{{ value_json["eta"]["value"]["@strValue"] }}'

It works great for most of the valus, however for some the string has , instead of . and then I got an error. So the question, how do add to the template so it transform the , to an .

marble jackal
#

I find it a bit strange that it sometimes uses . as decimal seperator and sometimes ,

#

but if that is indeed the case, you can use

value_template: '{{ value_json["eta"]["value"]["@strValue"] | replace(",", ".") }}'
analog mulch
#

Hi!. What's the correct device_class to use for prices (prices per unit I guess)? I tried monetary, but this only accepts totals as state_class which is not appropriate. I'm tyring to use template sensors to calculate average gas prices or statistics about the cost of running my car.

marble jackal
#

A device_class is not required, you can just not provide the line

#

it's also not required for long term statistics, unit_of_measurement and state_class are

terse scarab
#

@marble jackal I 'made' this: {{ int(states.sensor.aeg_droger_appliancetotalworkingtime.state) | timestamp_custom('%d days and %-Hh', false) }}
How do i get that working inside the entity? e.g.:
type: entities
entities:

  • entity: sensor.aeg_droger_appliancetotalworkingtime
    name: Appliance total working time
terse scarab
#

oh you can turn them int 'function' like things i read

marble jackal
#

you can create a template sensor

#

@terse scarab what is your end goal here, you want to display the time on on your dashboard?

formal ember
#

whats a good resource for writing a template, for example for a Title card in the UI, to say 'Currently its 22 degrees and sunny'

#

essentially it would be returning a state attribute from my weather entity no?

mighty ledge
#

typically frontend can't handle templates, so you'd first need to find a card that accepts them

formal ember
#

yeah the mushroom title card does accomodate that

#

am reading the Template docs on the HA Site but can't quite make sense of it (i am also burnt out lol)

#

I think I just got it...

#

Currently, it's {{ state_attr('weather.home', 'temperature') }}

mighty ledge
#

yep

formal ember
#

nice! funny pickup on my previous post haha

#

sometimes just have to type it out to realise what direction I need to be heading 🙂

terse scarab
#

@marble jackal Yes i want to show that in the dashboard.

marble jackal
#

You could create a template sensor then, or display it using a card which supports templates (a markdown card for example)
If you go for the template sensor route, you could create a sensor which shows the date and time it should be ready (so the current time + the number of seconds). That will be displayed on the frontend liek In 10 hours or In 46 minutes

#

(only the highest time fraction)

terse scarab
#

So an entities card is never gonna work for it?

#

ok works

#

(I added markdown card, works right away)

#

Yeah i think i prefer doing it straight in the card. Much less cumbersome and instantly see the result when trying stuff. Thank you 🙂

marble jackal
#

An entities card needs an entity

#

so that would be your template sensor

terse scarab
#

Everyone making wheels.

plain magnetBOT
#

@twin compass I converted your message into a file since it's above 15 lines :+1:

twin compass
#

which is giving me this error:

Error rendering data template: TemplateRuntimeError: No filter named 'weekday_full_name' found.

#

is there something wrong in the elif statements? cause before the elif it was working

mighty ledge
#

| is apply filter

twin compass
#

oooooo

#

let me try that 😄

#

it worked! thanks a lot!

mighty ledge
#

with or statements, it's best to make that a list anyways

twin compass
#

would that be 100% necessary?

mighty ledge
#
{% if weekday_full_name in ["Monday", "Wednesday"] %}
twin compass
#

ok i like that

mighty ledge
#

also, Saturnday?

#

typo

twin compass
#

yeah hahahahah

#

Thanks mate

weary canyon
#

I have a simple automation where 'When person enters Home zone' then 'Unlock front door'. I would like to add a condition where this were to only trigger if the Person has been 'Away' for at least 1minute.

Struggling to use templates to see previous states to make this work

acoustic urchin
#

Is there a way to display a duration sensor with days as the maximum unit instead of hours?

final trellis
#

please can you help me with the following template

#

as soon as I insert the random function it crashes

weary canyon
mighty ledge
#

there should be no "crashing", that's not something HA would do. Are you saying it produces an error? If yes, post the error.

mighty ledge
weary canyon
final trellis
#

it is the intentation on the random part

mighty ledge
#

that part looks fine

inner mesa
mighty ledge
final trellis
#

yes it does. but when it is inserted it within the if statement of the specific person it doesn't return an error

#

but it doesn't run either. I bet it has to do with intentation and quotes

weary canyon
inner mesa
#

You cannot do it in the UI

final trellis
#

I've tried to correct the intentation a bit
but it still doesn' run (

final trellis
#

i know it does

mighty ledge
#

indentation only matters with yaml

#

what you're writing is jinja, that's all inside the yaml field

#

100% makes no difference

final trellis
#

but it doesn't run.
if i delete the random function within the statement "makis" it will work for statement 'xxx'

mighty ledge
#

I'm not sure what to tell you, there should be an error if it doesn't run

#

are you just saying "there's no error" but you aren't checking the logs?

final trellis
#

it's not a yaml error. i think the tts engine doesn't parse it

mighty ledge
#

Yeah, you aren't looking in the correct place for errors

#

you have to check homeassistant.log

#

for jinja errors

final trellis
#

please accept my apologies - i will try once more

weary canyon
mighty ledge
#

no need to apologize, it's not straight forward. You'll learn where to check in time

mighty ledge
weary canyon
mighty ledge
#

not without messing with your person

weary canyon
#

Ok thank you again, will try it tonight

final trellis
#

the problem was n't in the action part

plain magnetBOT
#

@final trellis I converted your message into a file since it's above 15 lines :+1:

final trellis
#

thank you petro, once more you are more than expected ...!

inner mesa
#

Like a Transformer?

marsh cairn
final trellis
#

please excuse a newbie question. I was experimenting with calendar events to TTS
although I have an event response this is not been announced. No errors
What I'm doing wrong ??
https://dpaste.org/yHG59

#

i get an error on jinja template

2024-01-29 23:13:51.692 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'events' when rendering '"{% for event in agenda.events %} 
{{ event.summary }}: at {{ as_timestamp(event.start) | timestamp_custom('%-I:%M %p') }}
{% endfor %}"'
silent seal
#

The agenda doesn't have a property called events.

final trellis
#

is this not a property named events ???

lyric comet
#

No it is calendar_personal.events.summary as far as I can see.

final trellis
#

i dont want the summary only - i can get this from attrbute ...

#

i want a for loop

#

with all the information

#

i thought i could do a loop with the "events"

lyric comet
#

You can, but you only have one event in the result, try extending the amount of time to show more events.

silent seal
#

Yeah, in my test the agenda object has a property called calendar.personal and then events is within that.

final trellis
#

pls excuse my ignorance. I just started with calendar

#

🙂

#

I lost you

#

the problem is that I have no tts.

#

if i just a simple text before the start of the loop I hear it.

silent seal
#

You need to change the start of the for loop:

#
{% for event in agenda['calendar.personal'].events %}
final trellis
#

now we talking 🙂

#

it worked 🙂

#

thank you!

final trellis
#

for daily events my service call is correct right ?

silent seal
#

Well, yes and no. Assuming your trigger is only run once a day, then it will get all the events in the next 24 hours.

final trellis
#

ok, however it starts from now() , correct?

silent seal
#

Yes

#

But if it runs at 11pm, it'll tell you about the 7am event, and if it runs again at 6am, it'll tell you about the 7am event again.

#

It's up to you if that's really what you want.

final trellis
#

so if a PIR triggers it at 08.00 am , I will get the events until next day at 08.00

silent seal
#

Yes

final trellis
#

what does it means? "Event end was adjusted to prevent negative duration"

#

when i add a new event with start 7/2/2024 it goes and adds end 08/02/2024

silent seal
#

It's very likely something like:

  • Event start 8pm
  • Event end 2am
#

But if the dates are the same, then the event would "run backwards" from 8pm back to 2am the same day, which is what it's trying to fix.

inner mesa
#

going back in time requires additional hardware

hard zealot
#

hello, could someone please advise why i am unable to save this into an automation action:

service: "{{ service }}"
target:
  entity_id: "{{ entity }}"
data:
{%- if brightness == 0 %}
  brightness: "{{ brightness }}"
{% else %}
  {}
{% endif %}
#

it's saying something about message malformed, could not determine action. template seems to work fine in template tool

silent seal
#

Well, your automation doesn't know what service, entity, or brightness are

#

You'll need to figure out what you set those variables to in the template editor, and get the correct trigger variables/whatever it is you need to make it work.

hard zealot
#

it's defined in previous step (variable)

inner mesa
#

also, you can't template keys like that

hard zealot
#

so i'd need to make an if/then block?

silent seal
#

Or a choose, but without seeing what your whole automation looks like, we're just taking guesses

inner mesa
#

yes

hard zealot
#

ok, thank you.

final trellis
#

about calendar, when the state changes ?

#

obviously when the event occurs, the state will change when the time of the event comes. correct?

#

am looking for a condition, before I execute the TTS action

#

to prevent an empty TTS ... announcement

#

the condition am looking is "if there is an event for the day"

silent seal
#

You probably want an if or a condition with a template in it.

#
{% agenda['calendar.personal'].events != [] %}

Or similar.

final trellis
#

maybe like this ??
{{ agenda['calendar.personal'].events | count > 0 }}

inner mesa
#

Should be okay

karmic bluff
#

Hey guys, im trying to make a template sensor that is either off or on based on if the climate ac state is auto or off.
the helper does change but has the coding in the value

template:
  - sensor:
      - name: "Bedroom AC Power Status"
        state: >
          {% if is_state('climate.bedroom_ac', 'auto') %}
            on
          {% else %}
            off
          {% endif %}
#
Preview:
Bedroom AC Power Status
template: - sensor: - name: "Bedroom AC Power Status" state: > off
#

the helper has the code in the value

silent seal
#

You likely just need {{ is_state('climate.bedroom_ac', 'auto') }}, but you should make sure it's a binary_sensor, not a sensor

#

And you should probably change the > to >- so that white space is removed in your output.

karmic bluff
#

{% if is_state('climate.bedroom_ac', 'auto') or is_state('climate.bedroom_ac', 'heat') %}

silent seal
#
{{ is_state('climate.bedroom_ac', 'auto') or is_state('climate.bedroom_ac', 'heat') }}
karmic bluff
#

Thank you! been at it for a while

#

is it possible to do something like.
get an automation to count how long its on for the day and have a history of that value for the day ?

silent seal
#

An automation itself shouldn't be on for that long, but you can use the history to see how long an entity is on for.

karmic bluff
silent seal
#

YAML

karmic bluff
#
  - platform: history_stats
    name: Bedroom AC Daily Usage
    entity_id: binary_sensor.bedroom_ac_power
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    end: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
    duration:
      hours: 24
#

does that look right ?

silent seal
#

The end is wrong

#

end: {{ now() }} is what you need

#

Otherwise it'll be really confused by the window being from midnight just done to midnight just gone

karmic bluff
#

okay Thanks for the help! so i can use that as like an entity on my bedroom ui page ?

silent seal
#

Once you have reloaded your config/restarted and it shows up, yes.

karmic bluff
#

sweet restarting now so i'll test if it does anything 🙂

silent seal
#

I would recommend adding a unique_id as well, it's good practice

karmic bluff
#

unique_id: bedroom_ac_daily_usage ?

silent seal
#

That would be a good one.

karmic bluff
#

17.291, but the graph shows 0.00480

lofty mason
#

17 seconds = .004 hours

#

the duration class sensor format is a little weird and not immediately intuitive :\

karmic bluff
#

argh ok, so if its on for 1 hour it will be 3600

lofty mason
#

nah it will eventually show mm:ss and eventually hh:mm:ss

karmic bluff
#

okay ill turn it on for a min to see how it changes the formatting

#

okay cool so it just changed to 1:15

#

thank you both! made this alot less complicated 🙂

swift abyss
#

are todo lists usable via template yet or is that still in development? Just trying to add some todos to my morning announcement and not able to find any docs on doing it

haughty breach
swift abyss
#

I want to return a list of items to be read off by tts

haughty breach
#

Just modify it to use your notifier of choice.

swift abyss
#

ok thanks I'll take a look

sturdy yarrow
#

Hello! I have a D1 mini device running esphome. In home assistant this is a "press" button to toggle on/off. I have a button template that should give me a "real" on/off button instead of a press. Which it does, but when I use button.turn on, if it's already on it then turns off.. Is there a way to fix this?

plain magnetBOT
#

@sturdy yarrow I converted your message into a file since it's above 15 lines :+1:

silent seal
#

That's because the template switch is trying to send the "on" command again. You probably need to use a script as an intermediary, and call script.icemaker_on and have the script check if the binary sensor if off before sending the button press, and the same for the inverse

#

(Usually devices are state aware, or can handle things like this themselves. E.g. if you tell a blind to open and it's already open, it will either ignore it, or make sure it is open by briefly running the motor)

sturdy yarrow
#

Ah yeah, it kinda makes sense to me when you say it.. Can I maybe use an if statement inside the template? If I need to make a script too for this, it would probably be easier to find a way to change the code in the D1 mini running the icemaker 🤔

summer arch
#

I was looking at making a binary sensor for bedtime. I was going to set this based on phone charging after 11.

Should I have 2 triggers, charging state and 11? Then the state is after 11 and state charging?

#

Additionally, how would I check for after 11pm and before 6am (to account for plugging it in after midnight)

keen heath
#

Hello all

#

so I want to take my sensors and calc them together?

#
    - name : "Mains_L3_watts"
      state_topic: "***/*****/Mains_L3_watts"
      value_template: "{{ value_json['****'].P004.get('R064', 0) / 1000 }}"
    - name : "Mains_L2_watts"
      state_topic: "***/*****/Mains_L2_watts"
      value_template: "{{ value_json['*****'].P004.get('R062', 0) / 1000 }}"
    - name : "Mains_L1_watts"
      state_topic: "****/****/Mains_L1_watts"
      value_template: "{{ value_json['****'].P004.get('R060', 0) / 1000 }}"```
#

please can someone help?

thorny snow
#

I'm currently (trying) to write a JSON sensor to pull data from a community wind farm i'm apart off, display it in home assistant. i have the figure i'm looking for in the dev-> template tab but my yaml sensor returns unknown, if anyone could take a look over what i've done i'd appreciate it, json sample and my yaml are here: https://bpa.st/X2VJCRLNEFNBK344BKLG2WKS7I. thanks in advance

keen heath
#

@mighty ledge ? Sorry, are you busy ?

plain magnetBOT
#

Generally, don't tag people to ask for help - it comes across as bad manners, you’re demanding somebody answers you. It’s different if you’re thanking somebody, obviously. If you do tag somebody keep it polite and respectful. Remember that everybody is a volunteer, and nobody has to help you, and people may block you.

Similarly, please don’t DM (direct message) people asking for help. It also comes across as demanding, and means that others can’t learn from what you do.

Finally, please keep tagging people in replies to a minimum. That too can become annoying very quickly and should be used only when it's necessary (such as if it's been a long time, or there's multiple conversations going on). When using Discord's new Reply feature it defaults to pinging the person you reply to, click @ ON to @ OFF to stop this - on the right side of the compose bar.

thorny snow
#

not in the log, grep'd for ripple

#

[lime@lime-82v6 hass_config]$ cat home-assistant.log.1 | grep ripple_sensor [lime@lime-82v6 hass_config]$ cat home-assistant.log | grep ripple_sensor [lime@lime-82v6 hass_config]$

obtuse zephyr
#

I'd suggest restarting again and checking for errors in general, perhaps itll show under rest

thorny snow
#

i'll tail -f it, watch it as i restart

#

still not in it, not under rest, or sensor, or ripple

obtuse zephyr
#

How is that config snippet included in your configuration

thorny snow
#

sensor: !include_dir_merge_list sensor then a local dir called sensor

obtuse zephyr
#

Still think you're missing something in the log, but I'd probably enable debugging for rest and see what's up

homeassistant.components.rest: debug in your logger->logs

thorny snow
obtuse zephyr
#

Yup... keep going, there should be more

thorny snow
#

but still

#

2024-01-30 14:01:01.457 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: {"error": "Not authenticated"}

obtuse zephyr
#

There you go

thorny snow
#

almost certainly

#

if i;ve copied my api key in secrets wrong all this time and thats all thats wrong

#

thanks, copied and pasted the API wrong, must have included a trailing space or something

#

now i can play with the data i want to pull

#

is there a way to have the url hardcoded and only input the api into secrets ?