#templates-archived

1 messages Β· Page 102 of 1

violet oyster
#

then you have an entity that always shows that time.

rugged lichen
#

that would be perfect. can I get some short help with that I never tried something like that.

deft timber
#

I use {{ relative_time (states.binary_sensor.yoursensor.last_changed) }}

violet oyster
#

oh so there is an attribute

rugged lichen
#

yes but my sensor does not have attributes

#

as I know.

violet oyster
rugged lichen
#

this is an mqtt motion detector inside the camera.

violet oyster
#

i have never used a timer per se so i don't know too much about them. but it should work.

rugged lichen
#

yes, i tried it. Last_changed attribute not working.

deft timber
#

Do you have recorder integration activated ?

rugged lichen
#

Yes I have

deft timber
rugged lichen
#

Yes I have history too

#

interesting.

#

I see what you say, and understand it too, but my attribute last changed not working.

#

I want to see it on my apple watch.

#

This is what I wrote : {{ relative_time(states.binary_sensor.motion_detection_kitchen.last_changed") }}

#

Ah it works!

#

Sorry @deft timber Your Idea was the perfect!

#

It was my stupidness to misstype it!

#

Thank you for your kindness!

deft timber
#

πŸ‘πŸΌ

rugged lichen
#

Barbados also thank you for the hints πŸ™‚

violet oyster
#

you got it

rugged lichen
#

Sorry @deft timber a last question. How often does this update? I show this values on my apple watch.

#

Ah now its changed, but I dont know how much time spent.

deft timber
#

But hmmm, just made a little test, not sure it does...

rugged lichen
#

that would be very good to know, for example for me on my apple watch would be good to always see the actual stuff not 15 minute old.

deft timber
#

what you can do is what is proposed at the end of the webpage I linked : add an automation every x minutes that will update your template sensor using the service homeassistant.update_entity

violet oyster
#

yeah i have like 30 entities in my homeassistant.update_entity automation

rugged lichen
#

understood. I can do that. Thanks for the hint guys, sounds logical and easy.

violet oyster
rugged lichen
#

@deft timber interesting,because I created a markdown card where I show this template stuff and this is showing always the actual, every second. but on my apple watch only every 5 minutes lets say.

deft timber
#

Yes I guess that if the template is used directly in the front somewhere, it is the frontend that decides when the refresh occurs, and maybe this refresh rate is not the same on the apple watch and on the webapp ?! Just try guessing here πŸ™‚

rugged lichen
#

yeah I think the same anyhow I try your idea with the automation.

violet oyster
#

i would guess it is the apple watch refresh rate that is the problem

#

if it refreshed every second it would die in an hour

rugged lichen
#

not working 😦

#

yeah refresh every 5 minute would be also good.

#

but now it looks like its never doing it.

#

still showing the values of 20 minutes before.

violet oyster
#

but the value in the HA front end is correct?

rugged lichen
#

yes, it is changing every second.

violet oyster
#

yeah. i don't have an apple watch but that has to be a limitation of the watch

#

you might be able to use browser_mod to force a lovelace refresh on the watch. if it is using lovelace. or is it an app?

rugged lichen
#

you iphone?

#

you have iphone?

violet oyster
#

no, android

rugged lichen
#

I have app settings in IOS Home Assistant, there is an Apple Watch menu, you can change the status symbols in the front of the apple watch, where is your heart rate and things like that, it can show sensor values instead of these stuffs.

#

and you can write in templates. and I wrote in this: {{ relative_time (states.binary_sensor.motion_detection_kitchen.last_changed)
}}

#

and its showing 16 minutes. he thinks this is the time left since I was in the kitchen.

#

but I went in 10 minutes ago, and on my lovelace its changed.

#

it showing 9 min 30 sec.

#

but my watch still shows 26 minute old data.

deft timber
#

I don't have an apple watch sorry... does it do the same for all sensor ? It displays an old value ? Or only with this template ? If only with this template maybe you can create the template sensor we talked about, refresh it every minute with an automation, and display the value of this sensor instead of displaying the template ? Just an idea, I can't test it

rugged lichen
#

I tried the automation.

#

but didnt worked 😦

deft timber
#

oh !

violet oyster
#

what happens if you turn off bluetooth on your iphone to disconnect the watch and then turn it back on to reconnect? does it update?

rugged lichen
#

I tried it, didnt worked.

#

still showing 32 minute old data.

#

I really dont understand why is it a feature if it cannot be refreshed ever.

violet oyster
#

is the value correct on you iphone?

#

your*

rugged lichen
#

I can do a preview test.

#

on my phone with the template.

#

Yes

#

its working on my preview.

#

ah now its refreshed on my watch!

violet oyster
#

i'm wondering if you have the feature 'automatically close connection' turned on for the iphone app

#

i'm almost certain that is the problem

#

could be wrong but i have a strong feeling

#

or possibly if the iphone has some kind of power saving feature that puts the app to sleep

#

it won't update on the watch if it doesn't update on the phone.

rugged lichen
#

nothing like this on iphone

#

as I know.

#

everything set correctly on my phone

#

I check again.

violet oyster
#

so in your HA iphone app, click on your username at the bottom of the left pane

#

and see if 'automatically close connection' is turned on

rugged lichen
#

Ahh so its on the app

#

not on the phone settings.

#

Yes its enabled!

violet oyster
#

it could be either one causing it

#

turn that off and see what happens.

rugged lichen
#

need restart for that on the server?

violet oyster
#

no

#

that feature was introduced pretty recently and caused a lot of problems for me

#

it is intended to save bandwidth and battery but will also ruin functionality for things like you are trying to do

rugged lichen
#

I see, I read the blog now about this topic.

#

still the watch not refreshing.

violet oyster
#

is the app open on the phone?

rugged lichen
#

but that was a good hint.

#

yes

violet oyster
#

i wonder if there is a similar setting for the watch itself. i have no idea what the watch app is like

rugged lichen
#

I found something.

#

on the companion ios app docs.

#

By default the app will sync your sensor every 30 minute although the first update after creating a sensor may take longer.

violet oyster
#

can it be adjusted?

rugged lichen
#

No, only if you enable Background Fetch, what I think its enabled and set it on your apple watch home screen

#

both was done already.

#

15 minute left since the last watch update.

#

I'll wait again 15 minute and lets see if its real.

#

If yes its still bad πŸ˜„

#

motion detection with 30 minute delay a bit useless I think so.

violet oyster
#

i agree

rugged lichen
#

I dont know what should I use then, instead of that sensor.

violet oyster
#

an android, lol

rugged lichen
#

what would give important value for me to check it

#

πŸ˜„ πŸ˜„ nice

violet oyster
#

way more options with android

rugged lichen
#

The best would be an Apple HomePod

#

but too expensive

#

you can create automations on IOS with a default software called Shortcuts.

#

for example Call-service from Home Assistant.

#

and if you name it in any language, Siri will recognize it.

#

Im from Hungary and none of the voice assistants speak this language

#

but IOS recognize it because of this shortcut stuffs.

#

so I would be able to do everything with voice in my own language.

#

Now I use google mini.

violet oyster
#

home assistant users who use apple devices blow my mind. apple's sandbox is antithetical to the whole idea of open source home automation. but to each their own I suppose.

jagged obsidian
#

they're just rebels

rugged lichen
#

u are totally right, but still apple have more intelligent things like android.

#

and nobody can no.

#

because what I told it cannot be done anyhow with any apk or hack or anything on android.

#

so little differences, but yes on the other side on android you can do 99% more things.

#

customized also

violet oyster
#

google doesn't know your language? why does it have to be siri

rugged lichen
#

yes none of them know.

#

only Siri

#

also cannot speak it

#

but understands it.

#

for google will be in a 10 year period.

violet oyster
#

what language is it

rugged lichen
#

Alexa will never know they announced.

jagged obsidian
#

that's some halfassed job done by apple

rugged lichen
#

Hungarian

violet oyster
#

google home can't speak hungarian??

rugged lichen
#

No.

#

Alexa same.

violet oyster
#

man that sucks

rugged lichen
#

yes πŸ˜„

#

Now what im doing

#

I speak in english to GOogle Mini

#

and I wrote automations with Google Translate, so If I tell "Google turn on the livingroom light" its turn on and run Google_translate on Hungarian language and says back "Light is on" but on hungarian language with robot translate sound πŸ˜„

#

but apple homepod is about 400 usd, Google Mini I bought for 35 usd.

#

thats the difference, and thats the same thing nearly.

jagged obsidian
#

why is it important to have responses in native language?

rugged lichen
#

not important

#

the commands would be important

#

but native language response I can do, but commands are impossible only working with HomePod.

#

thats my problem πŸ˜„

jagged obsidian
#

only if you have nonenglish speakers in your home

rugged lichen
#

Yes.

violet oyster
#

ohhhh

rugged lichen
#

I just hate those people who came into my place. I tell to google turn on the lights.

#

Ahh you have a smart home? and it cant speak hungarian? then why you do this, its worth nothing then.

#

happened already twice πŸ˜„

violet oyster
#

i totally get that hahaha

rugged lichen
#

makes me sick πŸ˜„

jagged obsidian
#

i tell those people to stop being backward nationalists and to be glad its not in chinese

violet oyster
#

looool

rugged lichen
#

agree πŸ˜„

jagged obsidian
#

we live close by, its a similar mentality

rugged lichen
#

anyhow I hope google will do this sometime, it just a plus feature, what I would use.

#

where are you from?

jagged obsidian
#

i don't think hungary is high on their list

#

same with croatia

rugged lichen
#

ah nice country, we are really close then right πŸ˜„

#

my Idea was to go holiday to croatia, but the virus stuff solved that problem πŸ˜„ πŸ˜„ πŸ˜„

violet oyster
#

you should both move to the USA. you can stay in my house

jagged obsidian
#

other countries didn't mind πŸ˜„

#

no thanks πŸ˜„ i prefer a safe country like syria

violet oyster
#

lol fair

#

savage, but fair

jagged obsidian
#

not really but its a running joke here sadly

rugged lichen
violet oyster
#

hahahahahahahahaha

#

never seen that

#

we do like guns

rugged lichen
#

best smart home stuff ever.

#

even the music turn on some badass music and the light delay is perfect πŸ˜„ πŸ˜„ πŸ˜„

violet oyster
#

do you have any idea how much those guns would have cost lol

rugged lichen
#

Yeah I'll go to the local tesco and use 10 bucks kid weapons for 5 year old kids.

#

Apple watch didnt refreshed since 35 minutes 😦

#

Ah I started home assistant and refreshed

#

so 30 minutes is real,but need manual start to refresh

daring musk
dreamy sinew
#

i can't think of a way to reduce that logic

#

i see why you did it. I'm not sure if that's the best way to go about it, but it would work

marble jackal
#

You could also create a separate sensor for corrected elevation which uses sun.sun elevation and subtracts 1 is it's cloudy and an additional 4 for winter, 3 for autumn etc. And then use that new sensor to determine your corrected sunrise.

sly thistle
#

Can someone tell me why this sensor isn’t updating with the current value for now()?

   ac_last_changed:
    friendly_name: 'AC Last Changed From Present'
    unit_of_measurement: 'seconds'
    value_template: >-
      {% set CONTROL = 'sensor.be469zp_connect_smart_deadbolt_access_control' %}
      {% set CONTROLlc = states.sensor[CONTROL.split('.')[-1]].last_changed %}
      {{ as_timestamp(now()) - as_timestamp(CONTROLlc) }}
#

The value for CONTROLlc is static, but now() is changing constantly, so the template sensor should change. But it’s not

dreamy sinew
#

now() doesn't trigger a sensor to update. you need a datetime sensor

sly thistle
#

Is there such a sensor?

silent barnBOT
sly thistle
#

@surreal ether you commented on the forums on something similar. What I’m trying to do is to create a sensor which returns the number of seconds a control has last been updated from the current time.

   ac_last_changed:
    friendly_name: 'AC Last Changed From Present'
    unit_of_measurement: 'seconds'
    value_template: >-
      {% set CONTROL = 'sensor.be469zp_connect_smart_deadbolt_access_control' %}
      {% set CONTROLlc = states.sensor[CONTROL.split('.')[-1]].last_changed %}
      {{ as_timestamp(now()) - as_timestamp(CONTROLlc) }}

Now this won’t work because apparently I need to use a datetime sensor to calculate what β€œnow()” should be. Do you have any ideas on how to write this sensor? I pinged you on the forum thread.

dreamy sinew
#

looking at it, that seems kinda dumb

#

{% set CONTROLlc = states.sensor.be469zp_connect_smart_deadbolt_access_control.last_changed %}

#

which might get around the problem on its own whenever that value updates

#

creating an extra var that doesn't need to be there

surreal ether
#

you'll have to link the forum post, I don't recall. Only place I'm using now() is for a history_stats sensor

dreamy sinew
#

especially since you immediately toss away part of the value

dull dune
#

Hey! Any tips on how to make a cover template for a garage door with a switch that both opens, closes and stops the garage door motor. I have connected a binary sensor to monitor if port is open or closed

charred dagger
#

Maybe you could keep the current state in an input_select? It probably won't be very reliable, though.

#

I.e. opening/closing/stopped.

dull dune
#

hmm, I'll look into it, thanks

#

Am I just bad at finding it, or is there no way to specify that if binary sensor has certain state, then cover should be considers as opened/closed

charred dagger
#

E.g with value_template: "{{ states('binary_sensor.door_open') }}"

dull dune
#

So I have to build a template first, correct?

dull dune
#

oh! got it working, thanks a bunch @charred dagger !!

daring musk
#

You could also create a separate sensor for corrected elevation which uses sun.sun elevation and subtracts 1 is it's cloudy and an additional 4 for winter, 3 for autumn etc. And then use that new sensor to determine your corrected sunrise.
@marble jackal thank you, actually good idea

quasi glade
#

I'm not sure if this is the right place to ask, but I'm trying to set the name of a button depending on the state of a sensor, I have the jinja code figured out, but how do I add it to the name part of my button? https://hastebin.com/jozadineni.cs

bitter atlas
quasi glade
#

Thanks, I'll try out the button-card instead πŸ™‚

#

I thought it might be possible using {{}} or something and I was simply doing it wrong

inner quest
#

I have a temperature sensor and a card that shows temperature history. Is there a way to use templates to derive a new "sensor" that computes rate of temperature change?

#

Even a crude method that would use a single point in time, say 1 hour ago, as T_0 and the temperature now as T_1 so I could display (and plot) (T_1-T_0)/1 hour in degrees per hour.

bitter atlas
#

@inner quest most people just use something like grafana for that

#

once you need to start accessing past states of a sensor things get tricky

inner quest
#

So, can grafana access past states? I'm on a docker install of HA so no add-on support. I'm sure there is a way to install grafana but before I go down that rabbit hole I want to know it will do what I need. By the way, where is HA storing past data such that it can show me the history of the sensor? I'm looking to access that data.

#

Oh...I see it is in an sqlite DB! Maybe I can find what I need there

bitter atlas
#

it stores it in a database much like how you would do to have grafana to utilize past records.

inner quest
#

hmmm...seems like grafana wants influx DB...but HA already has the data in sqlite. Two copies of the same data in two different DBs? That seems strange (but I'm a total newb so I don't know didly squat)

bitter atlas
#

that was written in 2018 so keep that in mind, but it's a good reference and should be good for the biggest part

inner quest
#

Ok.

sly thistle
surreal ether
#

i don't have anything to add besides what was previously mentioned. you need to use the date time sensor.

sly thistle
#

That’s what I don’t understand. How do I include it into my sensor, much less consume it

surreal ether
#

gives an example

#

the resolution of sensor.time seems to be one minute though, so it might not work for you

#

if you need a finer resolution, i guess you might have to use the automation example, or re-work your original automation in some way.

sly thistle
#

Yeah, 1 minute is not working for me

final parcel
#

I am in situation when sometimes the electricity is shut down several times and causes my bulbs to turn on same as restart Raspbery with Hassio. Any template to check which devices on when nobody home and send notification?

bitter atlas
#

@final parcel you will want to do an automation for that

final parcel
#

@bitter atlas yep, but it cannot be based on state change. Imagine scenario Electricity OFF > ON > Bulb ON and Raspberry starting > 3 min Home assistant ON > Automation based on state change of Bulb from OFF to ON will not trigger since the ON is from the start of Home assistant

bitter atlas
#

@final parcel you can use HA start as the trigger and conditions to check state of bulbs

#

automation will fire once ha is fully started

#

if the same thing happened every single time you could just have it set the bulbs to what you wanted even if by chance their states weren't updated in HA

final parcel
#

Thanks! Yep and thats the second scenario the state might not be update with the start, so how to solve that?

sly thistle
#

@surreal ether using an automation to update the sensor every second works

#

Not the most efficient solution, but whatever

bitter atlas
#

@final parcel well you could always add a delay to the actions to give it more time along with a condition to check if any change

final parcel
#

thats right

bitter atlas
#

I wouldn't go crazy with the delay, but it shouldn't take too long to update the states if they weren't updated already

final parcel
#

And second question.. How to filter out "Home assistant started" in history log? πŸ™‚

bitter atlas
#

can't help ya there

final parcel
#

Ok

#

But anyway, your help is great. Thank you!

sly thistle
#

@final parcel I added a condition to every automation, script, sensor, etc. that requires an input boolean to be enabled in order for it to be fired.

#

Pain in the neck, but it ensures β€œjunk” doesn’t fire

final parcel
#

@sly thistle i dont understand that :/

#

how does it make sense please?

wanton osprey
#

Quick question. I use value_template: "{{ states.binary_sensor.shellyflood_heating_room_flood.attributes.battery }}" to extract the battery state from my flood sensor. The problem is that the battery state binary_sensor.shellyflood_heating_room_flood is listed not as a value, e.g., 100, it is listed in percentage, e.g., 100%. The percentage sign causes problems with the Battery State Card Addon. How can I remove the %?

dreamy sinew
#

{{ state_attr('sensor.shellyflood_heating_room_flood', 'battery')|replace('%', '')|float }}

wanton osprey
#

@dreamy sinew It seems to work. Thank you very much.

sly thistle
#

/join lock-manager

dreamy sinew
#

wrong box?

sly thistle
#

Oops, how do you create a channel?

#

discord is free, but lame

buoyant pine
#

@sly thistle only mods/admins can add channels

rugged lichen
#

Hello Community, I would like to add an attribute from my climate (current_temperature) to my graph on my dashboard as a sensor or somehow else I dont know.

inner mesa
#

You'd need to create a template sensor to expose that attribute and then add that entity

rugged lichen
#

Yes im trying that right now πŸ˜„

#

was a bit too early to ask sorry.

inner mesa
#

some cards allow you to use attributes directly, but most don't

rugged lichen
#

Ahh that sounds interesting, I'll look for that.

inner mesa
#

np, always happy to hear that folks have worked it out on their own

rugged lichen
#

πŸ™‚ best feeling

rugged lichen
#

@inner mesa I tried it, I was able to add it but diddnt worked well, so I tried to add the celsius sign at the end maybe thats the problem but also not working.

#

It do it like that.

inner mesa
#

share your sensor template?

#

you didn't give it a unit_of_measurement

rugged lichen
#

Ah I see it.

inner mesa
#

maybe attributes don't get a unit_of_measurement automatically, but you can specify it in the sensor definition. If you don't, you get a "timeline"

rugged lichen
#

degrees right?

#

I understand.

inner mesa
#

I think you want "C"

rugged lichen
#

Yes

inner mesa
#

I found the whole list in teh code a while ago

rugged lichen
#

I use celcius

inner mesa
#

you may also want/need to set the "device_class" to "temperature"

rugged lichen
#

Thanks, I'll be able to do it with this information.

rugged lichen
#

Mission Completed. Working correctly.

fading hedge
#
  alias: Netflix Forward 3 minutes
  sequence:       
  - service: remote.send_command
    data_template: 
      entity_id: remote.livingroom
      command: |
        {% for i in range(0, 9) %}
        - forward
        {% endfor %}
  - delay: '00:00:01'
  - service: remote.send_command
    data:
      entity_id: remote.livingroom
      command:     
        - play          ```
#

^ is not working. dev tool gives correct output for loop but actual script does not do anything. no errors in log. any help with this?

dreamy sinew
#

I wonder if this will work
"{{ ['forward' for i in range(0,9)]|tojson }}"

#

Probably not

fading hedge
#

yeah. let me give a try.

#

it did not work.

dreamy sinew
#

Kinda figured

#

It would still output as a string

#

Which is probably why the original didn't work

fading hedge
#

I see.

buoyant pine
#

You can use the new repeat: option if you're on 0.113 or newer @fading hedge

fading hedge
#

yes. I am on 0.114

#

I heard about repeat, never actually used it. looks like this will work. Thank you!

#
  alias: Netflix Forward 3 minutes
  sequence:       
  - repeat:
      count: "9"
      sequence:
        - service: remote.send_command
          data:
            entity_id: remote.livingroom
            command:
              - forward
  - delay: '00:00:01'
  - service: remote.send_command
    data:
      entity_id: remote.livingroom
      command:     
        - play          ```
#

^ this works. Thanks @buoyant pine and @dreamy sinew for help.

bronze horizon
#

Cross-posting per Tinkerer's advice πŸ™‚ I'm trying to integrate all media devices in one room into a single UMP. The Ikea Symfonisk speaker remains in a 'paused' state indefinitely, but I want it to go to idle/off so that control goes to the next child to the list.

It seemed that the easiest way around this might be to proxy the Symfonisk through another UMP with a state_template that overrides the state with 'idle' after the actual speaker remains in 'paused' for 3 minutes.

Strangely, the if-template works as expected in Dev Tools > Templates, but the exact same template gives the incorrect fail status after 3 minutes:

  state_template: >
    {% if (as_timestamp(now()) - (3 * 60)) > (as_timestamp(states.media_player.b3d_symph0.last_changed)) and is_state('media_player.b3d_symph0', 'paused') %}idle
    {% else %}fail
    {% endif %}

Tinkerer mentioned that templates update when the entities in them change state, and now() is not an entity so it wouldn't prompt an update. I'm not too sure I understand, but is the issue that only changes to the media_player.b3d_symph0 state will prompt an update, and therefore will always be within 3 minutes (or 0 seconds) of the last_changed value and therefore never work out to idle as I'm hoping?

bitter atlas
#

I'm not too sure I understand, but is the issue that only changes to the media_player.b3d_symph0 state will prompt an update, and therefore will always be within 3 minutes (or 0 seconds) of the last_changed value and therefore never work out to idle as I'm hoping?
@bronze horizon more than likely

bronze horizon
#

Ah, just found the docs about calling the homeassistant.update_entity service to get around this. Sounds like what I need, but am I gonna cause problems updating every few seconds?

bitter atlas
#

no

bronze horizon
#

Ah, rad. Let's give this a shot then...

#

Heck yeah, ezpz!

jagged basin
#

Hello, needs some help with a template. I've got a tower fan that works off of IR to control the fan, I've installed a SP20 wall plug with Tasmota flashed to it. The wall plug can monitor power and current along with turn on and off through MQTT. The MQTT has set up sensors for the plug and I can see how much power the fan draws. What I would like to do is set up a template for a switch that returns the state on or off based on whether the plug switch is on and if the fan is drawing power above a certain threshold

inner mesa
#

what sensor content are you getting?

jagged basin
#

Energy Current and Energy power are what I'm looking at

#

power is in watts and current is in amps

#

right now the fan is on and its pulling 53 watts

inner mesa
#

do you need to parse the data coming from MQTT, or you already have the states you want?

jagged basin
#

already in a state that I want

#

I'm thinking some sort of IF

#

IE: if the power is = or > 50 watts the fan is on

inner mesa
#

ok, just trying to figure out if the fact that the data is coming from MQTT has any bearing on the solution. It seems not

jagged basin
#

but I also this it needs to check the switch state. If the switch is off, nothing is on

#

I've got a RM4 mini that I'll use to control the fan itself but I need to know the state before I send any IR codes to the fan

inner mesa
#

have you checked out the docs?

#

there are examples there that appear to cover your "IE: if the power is = or > 50 watts the fan is on" case

jagged basin
#

I saw the switch template and I'm not sure how to implement it

#

so the washing machine running binary sensor does look like what I want

inner mesa
#

A template switch is pretty straightforward, with examples on the page. It's just an optional status, which is the same as the value_template that you'd use in a binary_sensor and service calls for on and off (whatever you need to publish to MQTT, probably via mqtt.publish)

jagged basin
#

Ill give it a shot

#

thanks for the help

inner mesa
#

np

#

here's one of mine:

#
switch:
  - platform: template
    switches:
      downstairs_lights:
        value_template: "{{ is_state('group.downstairs_lights', 'on') }}"
        turn_on:
          service: homeassistant.turn_on
          data:
            entity_id: group.downstairs_lights
        turn_off:
          service: script.turn_off_downstairs_lights
jagged basin
#

got it working

#

the binary sensor docs did it.

#

now I just need to get the state from the plug faster then every 5 min

inner mesa
#

Good job! You’ll probably want #hardware-archived for Tasmota issues. Or their discord server

jagged basin
#

I seem to remember reading about it I just have to find that blog

#

just occurred to me that if I know the watts I can create a sensor to tell me if the fan is on low, med, or high.

inner mesa
#

Sure

jagged basin
#

now if I can make a switch that will do the laundry I'll be set

inner mesa
#

Fluff and fold is the tricky bit

jagged basin
#

HA

vagrant monolith
#

Why does this not work?
entity_id: "light.livingroom_window_1" brightness: "0" transition: "{{ range(1, 20)|random }}"

violet oyster
#

post the rest of it

vagrant monolith
#

I think i did it right now, the problem must been the int

day: sequence: - service: light.turn_on entity_id: light.livingroom_window_1 data_template: brightness: 0 transition: '{{ range(1, 20)|random|int }}'
Cause now it looks like it works. Thanks anyways! πŸ™‚

#

Also the problem with the entity id in data_template

violet oyster
#

yeah that shouldnt have quotes

#

looks right now

vagrant monolith
#

πŸ™‚

#

One weird thing tho

violet oyster
#

although in all mine i have entity_id under data_template

vagrant monolith
#

is that its turn off the lamp and turn on and then change transition as i see from the ui cause im not in the house rn

violet oyster
#

never tried it like that but if it works, whatever

#

i would use a scene for that function

#

not the light.turn_on service. i'd use scene.apply and set the transition there

vagrant monolith
#

I cant do the range there?

violet oyster
#

you should be able to do the range template with scene.apply or scene.turn_on if you want to pre-define it

vagrant monolith
#

How do you mean?

violet oyster
#

using it as a scene won't turn the light on if it is off already

#

give me a minute

vagrant monolith
#

You mean i can do like?
``

  • name: Day
    entities:

    Livingroom

    light.livingroom_window_1:
    state: true
    brightness: 0
    transition: '{{ range(1, 20)|random|int }}'
    ``
violet oyster
#
day:
  sequence:
    - service: scene.apply
      data_template:
        entities: 
          light.livingroom_window_1:
            state: "off"
            transition: '{{ range(1, 20)|random|int }}'  
#

i think that will work.

vagrant monolith
#

What would i gain of that?

#

I mean i wont the lamp to be on 0 brightness on next turn on

violet oyster
#

wait, you want to turn it on, or off?

vagrant monolith
#

off but next time i turn it on i want it to have 0 brightness

violet oyster
#

but then it would be off, right?

vagrant monolith
#

Yes

#

But off state does not change brightness on next turn on?

violet oyster
#

correct. but why would you want it to have 0 brightness next time?

vagrant monolith
#

Cause in norning when i then do a light turn on with transition and brightness at like 50 it maybe sets to 255 if it last state was that am i right? and then it decrease to set brightness

#

Which maybe woke me up before it should

violet oyster
#

i see

#

then in that case i'd use the same service to turn it back on in the morning.

day:
  sequence:
    - service: scene.apply
      data_template:
        entities: 
          light.livingroom_window_1:
            state: "on"
            brightness: 100
            transition: '{{ range(1, 20)|random|int }}'  
#

you don't have to do it that way, but it would work.

vagrant monolith
#

Would it? It would been last state and then decrease or increase until 100?

#

With that transition

#

I want it from 0 and then to 100 in that case

violet oyster
#

no, if it is off and then you apply that scene with a transition, it will go from off to 100

#

it works differently than the light.turn_on service.

#

at least that is my experience.

vagrant monolith
#

I can try πŸ™‚

violet oyster
#

worth a shot

vagrant monolith
#

It goes from last brightness to 0 then up

#

And both down and up has the transition

#

😦

violet oyster
#

really? wow. ok sorry lol

#

mine don't do that

vagrant monolith
#

How does your look?

violet oyster
#

just like I said

vagrant monolith
#

Weird then

violet oyster
#

maybe do the scene call the way you had it before my advice.

day:
  sequence:
    - service: scene.apply
      data_template:
        entities: 
          light.livingroom_window_1:
            state: "on"
            brightness: 0
            transition: '{{ range(1, 20)|random|int }}'  
vagrant monolith
#

Yea but then its weird cause it turn off lamp in ui then turn on and decrease it to 0 so yea

violet oyster
#

who cares about the UI tho?

#

all that matters is the behavior of the actual light, right?

vagrant monolith
#

Yea but im not in the house so i cant see

violet oyster
#

oh ok.

vagrant monolith
#

But!

violet oyster
#

if you want it to be off in the ui just add a delay then use light.turn_off after 20 seconds

vagrant monolith
#

I may can do a script i call in every script that sets everything to 0

vagrant monolith
#

Btw it works exactly like before but with random delay with your setup thanks! @violet oyster

#

I have no clue. Can i do like a script with a array like calling it with attribute ``to: [person1, person2, person3] and all these objects have a seperate action in one script?

violet oyster
#

yes, with the choose function

vagrant monolith
#

Can i? Does it go thru 3 actions if them all are true?

#

Like can i have a if, if, if there?

violet oyster
#

theoretically yes, youd just have to make a bunch of differerent chooser conditions for each possible combination

vagrant monolith
#

Ok can you maybe explain how i get the array into there?

#

Like can i even get a choose into a script?

violet oyster
#

look for "Automations & Scripts: Chooser"

#

then for the condition use a template condiiton

vagrant monolith
#

with one script that i can call with a attrubute like to: [person1, person2] or maybe only [person2] or [person1]

violet oyster
#

yeah you can merge them using the chooser. take the condition out of the script and use that as the chooser condition. then put the service in the chooser sequence

vagrant monolith
#

But can i call multiple ifs at same time?

violet oyster
#

what do you mean by ifs

vagrant monolith
#

if -> then multple of these to be called same time based on variable

bitter atlas
violet oyster
#
condition:
  condition: template
  value_template: "{{ if is_state('input_boolean.notify_person1_discord', 'on') and is_state('input_boolean.notify_person2_discord', 'on'), True }}"
#

if thats what you mean

vagrant monolith
#

No not really i cant explain xD

#

instead of calling mulitple scripts in automations for sending same message but to different persons on different conditions i want to call one script with a variable called "recievers" and value is maybe [person1] or [person2]or [person1, person2] then send the message to these persons defined there with different conditions and actions

bitter atlas
#

I would create a really complex template sensor to handle all the if's and output specific state at which an automation/script can be more easily constructed to follow without it being a complete nightmare

vagrant monolith
#

Can you give me a example of that?

bitter atlas
#

an example of a nightmare? uh no lol i wouldn't evven want to try and type that out lol

violet oyster
#

haha, i can. for my hvac automation

vagrant monolith
#

@bitter atlas no but for how you see a solution of this

#

Cuz i have multiple automations that have the action to send message but maybe with multiple recivers or only one

violet oyster
bitter atlas
#

you have all the entities in place to handle the different conditions right? well a template sensor can take those and compare then and then spit out different custom states based on the condition you set

#

yea like that what @violet oyster posted

violet oyster
#

i hate it lol

vagrant monolith
#

I will explain more

inner mesa
#

That isn’t a valid template, though

violet oyster
#

what isnt? mine?

inner mesa
#

Yes

violet oyster
#

how so? it works

inner mesa
#

If xxx and xxx, True?

vagrant monolith
violet oyster
#

oh i thought you meant my pastebin one

inner mesa
#

Sorry, the one above

#

A bunch of blocked messages are causing me to miss the context. I’ll step away... πŸ™‚

violet oyster
#

oh i don't need the if for the one you are saying

vagrant monolith
inner mesa
#

Or the comma, or the True

violet oyster
#

haha i typed it up on the fly. fuck me

#

@vagrant monolith like @bitter atlas said i would use a template sensor for that and 12 different scripts for all the different combinations of people who might need to be notified. or one script with 12 different chooser conditions.

#

would be close to the same lines of code either way.

#

or just keep it like you have it since that doesn't seem too bad.

thorny snow
#

Would it be a template that saves the last sane value? My weather keeps going "unknown" and I'd like to just save the last known good until it comes back.

amber terrace
#

@thorny snow I would create a template that copies the value except when it is unknown. That should keep it up to date with the last know value

slate osprey
#

Am I going about this the right way? (not tested this code yet)

dusky bane
#

Hi all! i have a quick question related to a simple problem

#

i'm adapting a template to calculate vapor pressure deficit

silent barnBOT
dusky bane
#

it gives an error i believe from {% set LT = states('sensor.leaf_temp') | float %}

#

it's an input_number really, i tried different methods to use this number i set in a box or a slider but don't figure it out

#

so my question is , how can i refer to a slider or box in a template ?

#

here is the input_number :

#

'''

input_number:
leaf_temp:
name: Leaf Temp
initial: 0
min: -10
max: 0
step: 0.5
mode: box

'''

#

sorry i don't remember how to format the text to yaml

silent barnBOT
#

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. Here's an example:

```
code here
```
Watch the animated gif here: https://bit.ly/2GbfRJE
DO NOT repeat posts. Please edit previously posted message, here is how -> https://bit.ly/2qOOf1G

inner mesa
#

wrong quotes

dusky bane
#

okay thx

inner mesa
#

it looks like you defined input_number.leaf_temp and are referring to it as sensor.leaf_temp?

#

that would be incorrect

dusky bane
#

i tried to refer to it in various ways,

#

input_number.leaf_temp won't work neither

inner mesa
#

you need to refer to it by the actual name πŸ™‚

#

does it work in devtools -> Templates?

#

"various ways" for sure won't work

#

what error are you getting?

dusky bane
#

i'm trying stuff in developper tools indeed but right now i'm confused sorry, thank you for the input, i come back eventually with a clearer problem πŸ™‚

#

ok i think i get it working, my problem were syntax and mathematical and confusion, thank you for help anyway

dusky bane
#

when you say i need ti refer to it by the actual name

#
input_number:
  leaf_diftemp:
    name: leafdiftemp
    initial: 0
    min: -10
    max: 0
    step: 0.5
    mode: box
#

i should refer to state('input_number.leaf_diftemp') or state('imput_number.leafdiftemp') or any other syntax ?

inner mesa
#

the first one

#

the name: is for display

#

always check devtools -> States for what things are called and their states/attributes

#

in all cases, refer to entities by their entity names, as shown in the first column

dusky bane
#

okay thank you for your guidance i got it working

honest mauve
#

Hi all

silent barnBOT
honest mauve
#

I Have this error

#
  - platform: template
    sensors:
      lavastoviglie_tempo_residuo:
        friendly_name: "Lavastoviglie - Tempo Residuo"
        unit_of_measurement: ' min'
        value_template: "{%- if states.sensor.lavastoviglie_remaining_program_time.state != None -%}
                           {{((as_timestamp(states.sensor.lavastoviglie_remaining_program_time.state)-as_timestamp(now()))/60) | int }}
                         {%- else -%}
                            0
                         {%- endif -%}"```
#

That's my sensor

#

I check if it's None

#

but it seems not to work

#

how can I fix it?

dusky bane
#

Hi all! I try to formulate a condition to activate action if value goes below or above 1 and 1.45 :

#
    condition:
      condition: or
      conditions:
      - condition: template
        value_template: {{ (states('sensor.vapor_deficit') | float < 1) }}
      - condition: template
        value_template: {{ (states('sensor.vapor_deficit') | float > 1.45) }}
#

i don't understand the error :
``

#

invalid key: "OrderedDict([("(states('sensor.vapor_deficit') | float '< 1')", None)])"

#

someone can enlight me ?

#

oh okay forget it

#

It happens sometime i try to figure out something for hours and when i ask for help i find the solution in the next minute

honest mauve
#

add .state at the end

#

use [] instead of ()

#

states['sensor.vapor_deficit'].state

#

@dusky bane does it work?

dusky bane
#

thank you for your input @honest mauve i just forgot "" like that : "(states('sensor.vapor_deficit')" and it was solved

#

"{{ (states('sensor.vapor_deficit') | float < 1) }}" i mean

honest mauve
#

ok

honest mauve
#

I Have this error : https://paste.ubuntu.com/p/M8VYMN949R/

  • platform: template
    sensors:
    lavastoviglie_tempo_residuo:
    friendly_name: "Lavastoviglie - Tempo Residuo"
    unit_of_measurement: ' min'
    value_template: "{%- if states.sensor.lavastoviglie_remaining_program_time.state != None -%}
    {{((as_timestamp(states.sensor.lavastoviglie_remaining_program_time.state)-as_timestamp(now()))/60) | int }}
    {%- else -%}
    0
    {%- endif -%}"
    That's my sensor
    I check if it's None
    but it seems not to work
    how can I fix it?
fierce hornet
#

I've found a template online that should calculate the percentage of a timer. I still don't understand templates a lot, could someone tell me which parts I need to change to my own timer? (timer.ledtimer){% set timer = 'xxx' %} {% if is_state('timer.'~timer,'active') %} {% set state = states.timer[timer] %} {% set dur = state.attributes.duration.split(':') %} {% set dur = ((dur[0]|int)*60+dur[1]|int)*60+dur[2]|int %} {{ ((now() - state.last_changed).total_seconds()/dur*100)|int }} {% else %} 0 {% endif %}

brisk temple
#

@fierce hornet the xxx part at top. Set it for what is after timer.

#

so if you have a timer.super_timer you would change 'xxx' to 'super_timer'

fierce hornet
#

ahh, thank you!

dusky bane
#

i'm in the same kind of work now, i try to limit notifications to a certain time, because i receive it every minute

#

so this is the condition for the automation that sends the notification :

#
      - condition: template
        value_template: "{{ states('sensor.vapor_deficit') | float < states('input_number.vpd_min') | float }}"
#

after trying different stuff i have no result

#

i would like to add to the template that the result have to be true for a certain amount of time

#

do i have to use the same kind of timer methods or there is a shortcut ?

inner mesa
#

Use for:

#

Hmm, if that works for a template condition

#

Worst case, create a template sensor and a state condition with a for:

dusky bane
#

yes i tried a bit with for: but seems not intended to work in a template

inner mesa
#

Okay, so make a template sensor

#

Probably a template binary sensor in this case

dusky bane
#

i don't see how i can solve this with a template binary sensor, can you elaborate ?

inner mesa
#

Use the same template that you have there in a template binary sensor. The value will always be on or off

#

Then use a state condition based on that sensor with a β€˜for:’ clause

dusky bane
#

okay never use this way i will try it thank you for the idea

inner mesa
#

It’s just a roundabout way of doing a template with a for:. Maybe I’ll post a WTH about it

hollow bramble
#

Well you would need to track the state of a template to use for. Not sure how else you would do that without a sensor

dusky bane
#

i think i have something not sure if its working well but dont give error at least :

#
binary_sensor:
  - platform: template
    sensors:
      vpd_min_state:
        value_template: >-
          {{ states('sensor.vapor_deficit') | float < states('input_number.vpd_min') | float }}
        delay_on: '00:00:10'
inner mesa
#

yeah, or you could do that. I keep forgetting about the "delay_x*" options

dusky bane
#

yes i allways check the website documentation because im 0% autonomous because i'm new and then i found that

#

anyway thank you you put me on tracks

young jacinth
#

HI, i have a weird problem
i got this script: https://pastebin.com/aLL4Gwn8

every second time i call this script it wont turn my lights on, if i turned them off. no matter how long i waited etc. if i delete the template from the script everything works fine. someone has a clue?
is someting wrong with my template?

buoyant pine
#

yes, this:

brightness_pct: "{{ state_attr('switch.circadian_lighting_fl', 'brightness') | int }}"
``` should be this:

brightness: "{{ state_attr('switch.circadian_lighting_fl', 'brightness') | int }}"

#

@young jacinth

young jacinth
#

brightness gets reported in pct from circardian lighting. this does not solve my solution as the issue stays anyway

buoyant pine
#

oh, my bad

young jacinth
slate osprey
hollow bramble
#

What does the template render as in dev tools?

slate osprey
#

Oh I've never used taht feature, do I just paste my template in there?

hollow bramble
#

yup

slate osprey
#

I'm getting Unknown error rendering template

hollow bramble
#

You're using is_state incorrectly

#

just use states for what you're trying to do

#
{% if states('sensor.temperature') | int < 18 %}
  0
{% elif states('sensor.temperature') | int > 28 %}
  255
{% else %}
  {{ states('sensor.temperature') |int - 18 | multiply(25.5) }}
{% endif %}
slate osprey
#

Thank you!

#

This template render is a game changer! What an awesome feature

#

I'm trying to map the states('sensor.temperature') values between 18Β°C and 28Β°C to values between 0 and 255, but I'm having trouble figuring out the best approach to do this.

quiet lagoon
inner mesa
#

you need to filter the state values if you want them to be numbers

#

states are strings

#

so use |float

quiet lagoon
#

I use basically the same template in two automations. One has a > and the other has a < The template with the > renders correctly even without |float or |int

inner mesa
#

string math is weird

#

does it work when you add it?

quiet lagoon
#

I was testing option in the template tool and tried |int first which works for me. |float does as well. I think I am going to keep with |int as it add some cushion to the on/off of the automations. (going from 100F to 99.9F and back to 100F doesn't turn the switch on/off/on again. )

#

Thanks for the help.

inner mesa
#

np

slate osprey
#

It sure looks like an int in the template renderer

inner mesa
#

are you using 0.115?

#

if not, you need to use data_template:

slate osprey
#

Oh I see

inner mesa
#

or wait until Thurs πŸ™‚

#

(0.115 release)

slate osprey
#

hahaha i'm one of the last few who came across this error then

inner mesa
#

congrats

slate osprey
#

It's working now! Thanks for all the help

distant plover
#

I have this template that lists name, name, entity, entity. How can I make it show name, entity, name, entity? {{ state_attr('sensor.utilgjengelige_entiteter','names').split(', ') | join('\n') }} {{ state_attr('sensor.utilgjengelige_entiteter','entities').split(', ') | join('\n') }}

distant plover
#

Did that make sense? πŸ™‚

rugged laurel
#

no

#

What's the attributes of that sensor?

deft timber
#

Would that do the trick? :

#

{% set names = state_attr('sensor.utilgjengelige_entiteter','names') %} {% set ents = state_attr('sensor.utilgjengelige_entiteter','entities') %} {% for nm in names.split(',') %} {%- set pos = names | regex_replace(nm+'.*', '') | regex_replace('[^,]', '') | length -%} {{ nm }} {{ ents.split(',')[pos] }} {% endfor %}

#

hypothesis to make this work, the names should be unique

dreamy sinew
#
{% set l2 = ["e1", "e2"] %}
{% set ns = namespace(things=[]) %}
{% for i in range(l1|length) %}
{% set ns.things = ns.things + [(l1[i], l2[i])] %}
{%endfor%}
{{ns.things}}```
#

output
[('n1', 'e1'), ('n2', 'e2')]

deft timber
#

Cool, didn't know about that range function

#

Then my version (if you work with strings and not collections) would be

#

{% set names = state_attr('sensor.utilgjengelige_entiteter','names') %} {% set ents = state_attr('sensor.utilgjengelige_entiteter','entities') %} {%- set size = names | regex_replace('[^,]', '') | length +1 -%} {% for i in range(size) -%} {{ names.split(',')[i] }} {{ ents.split(',')[i] }} {% endfor %}

dreamy sinew
#

the results of those things are just strings right?

#

lists of strings?

#

state_attr('sensor.utilgjengelige_entiteter','names')|list

#

what is the raw output of :
state_attr('sensor.utilgjengelige_entiteter','names')

desert quail
#

hi there people. Need a litle help. My ceiling have 13 gu10 rgb 6w bulbs that use tuya. Can anyone help me to create color cenes for tham, lke raibow for that group.

bitter atlas
#

@desert quail you should google around and even check out the forums. https://community.home-assistant.io/ I am sure someone has done something that will point you in the right direction on how to do what you want

desert quail
#

@bitter atlas already try that, but, i think I dint use the right querie :S

distant plover
#

The raw output of that is 'Gang - Range extender, OPPLE switch 2-gang Battery Level'.

dreamy sinew
#

ok, state_attr('sensor.utilgjengelige_entiteter','names').split(', ')

#

that'll get you a list that you can then directly use

distant plover
#

Uhm. I see I explained poorly. I would like a string saying: name1 (entity_id 1) name2 (entidy_id 2)

#

The latest output from slashback was pretty close. That shows:

Gang - Range extender
light.range_extender_5
 OPPLE switch 2-gang Battery Level
 sensor.opple_switch_2_gang_battery_level
dreamy sinew
#
{{ '{} ({})'.format(names.split(',')[i], ents.split(',')[i]) }}
{% endfor %}```
#

taking from @deft timber 's line above

distant plover
#
 OPPLE switch 2-gang Battery Level ( sensor.opple_switch_2_gang_battery_level)```
#

Where does the space in front of second line come from? And the space after the 2nd line first (

dreamy sinew
#

try ```{%- for i in range(size) -%}

#

its a templating thing

distant plover
#

No change

dreamy sinew
#

do {{- on the output line

distant plover
#

Like this? No change. {%- for i in range(size) -%} {{- '{} ({})'.format(names.split(',')[i], ents.split(',')[i]) }} {% endfor %}

deft timber
#

Strange. I tried
{% for i in range(size) -%} {{ names.split(',')[i] }} ({{ ents.split(',')[i] }}) {% endfor %}

#

and it works

#

a (n1) b (n2) c (n3)

dreamy sinew
#

i wonder if you have an extra space in your lists and that was getting caught

distant plover
#

I checked the attributes of the sensor and it's like this: entities: 'light.range_extender_5, sensor.opple_switch_2_gang_battery_level' names: 'Gang - Range extender, OPPLE switch 2-gang Battery Level'

dreamy sinew
#

because i wasn't able to repro with my test

deft timber
#

ok you have a space after the ','

distant plover
#

Yeah, I see

dreamy sinew
#

that would do it

#

that's why the split i posted had .split(', ')

distant plover
#

Eyy.. this worked {{ names.split(', ')[i] }} ({{ ents.split(', ')[i] }})

deft timber
#

I did it with
{% for i in range(size) -%} {{ names.split(',')[i] | regex_replace('^ *','')}} ({{ ents.split(',')[i] | regex_replace('^ *','') }}) {% endfor %}
byt phnx proposition is prettier

dreamy sinew
#

the "clean code" guy in me says you should split the list when you create it vs doing the split on every loop

deft timber
#

+1

dreamy sinew
#

post the full thing real quick?

distant plover
#

The one that worked was this {% set names = state_attr('sensor.utilgjengelige_entiteter','names') %} {% set ents = state_attr('sensor.utilgjengelige_entiteter','entities') %} {%- set size = names | regex_replace('[^,]', '') | length +1 -%} {% for i in range(size) -%} {{ names.split(', ')[i] }} ({{ ents.split(', ')[i] }}) {% endfor %}

dreamy sinew
#

yeah

distant plover
#

I'm gonna take your advice though and modify the sensor to show it without spaces

#

Maybe πŸ™‚

dreamy sinew
#
{% set names = state_attr('sensor.utilgjengelige_entiteter','names').split(', ') %}
{% set ents = state_attr('sensor.utilgjengelige_entiteter','entities').split(', ') %}
{% for i in range(names|length) -%}
{{ '{} ({})'.format(names[i], ents[i]) }}
{% endfor %}
distant plover
#

Oh thats what you meant "when you create it". I thought you meant in the sensor.

dreamy sinew
#

there, final edit

distant plover
#

Thanks a bunch

dreamy sinew
#

one less var. The output is "messier" in some regards but i like this method better because i day-job python

#

too bad jinja2 doesn't do fstrings

#

and if you decide you want to change the format, it is a bit easier

#

since you can leave the .format() bit alone and just add stuff to the string

wicked temple
#

I'm repost my question now since quackeds seems to be solved πŸ™‚

#

Hey everyone! So I'm wondering how I could go about calculating total space left on my unraid server. I have all my hard drives used & free values in home assistant already but I don't have a value that shows the total space left/used across them all. Is there a smart way to create this?

bitter atlas
wicked temple
#

These harddrives are not from HA

#

its from a seperate unraid server

bitter atlas
#

total space as in all drives added together?

wicked temple
#

I'm already getting "used" and "left" values from each individiual drive

#

Yeah exactly!

#

Its a matter of just calculating the sensors together, i just don't know how to do that

inner mesa
#

"math" πŸ™‚

bitter atlas
#

you would just create a template sensor with something like this "{{ states('sensor.something') | float + states('sensor.whatever') | float }}"

wicked temple
#

Another | for each drive?

#

I have 9 drives I want to add together

inner mesa
#

another "+"

#

states('xxx') is the state as a string, |float turns it into a float that can be used in mathematical expressions, + does the adding

wicked temple
#

{{ states('sensor.diskstotal') | float + states('sensor.glances_mnt_disk1_used_percent') + states('sensor.glances_mnt_disk2_used_percent') + states('sensor.glances_mnt_disk3_used_percent') | float }}

#

So something like this?

inner mesa
#

uh, no

#

you need to filter each state with |float

#

you missed the two in the middle

wicked temple
#

I'm sorry I'm really crap when it comes to this, I'm not sure I understand πŸ˜…

bitter atlas
#
{{ states('sensor.glances_mnt_disk1_used_percent') | float + states('sensor.glances_mnt_disk2_used_percent') | float + states('sensor.glances_mnt_disk3_used_percent') | float }}
wicked temple
#

Oh I see, lets try

#

Thank you

bitter atlas
#

don't do it phnx!!

dreamy sinew
#

{{ [states('sensor.glances_mnt_disk1_used_percent'), states('sensor.glances_mnt_disk2_used_percent'), states('sensor.glances_mnt_disk3_used_percent')]|sum }}

bitter atlas
#

and presto, we got blessed by a templating God.. i need a shower

dreamy sinew
#

it might do some magic under the hood

#

dunno if it works yet

wicked temple
#

Unknown error rendering template

#

Can't I use it it in the Template thingy under Developer tools?

dreamy sinew
#

yeah, its trying to math strings and bails

#

cast them all to floats and it'll work

inner mesa
#

That’s totally better πŸ™‚

wicked temple
#

Right, that gives me a value of 188.6

#

Ah, I need to divide it ofcourse

dreamy sinew
#

definitely 6 of 1 half-dozen of the other

#

oh, trying to average?

silent barnBOT
wicked temple
#

Not average, I want the total amount of disk space left

#

Wait im dumb

#

Yes, I can use this formula

dreamy sinew
#

oh, these are percentages

wicked temple
#

Just need to pick the right sensor haha

dreamy sinew
#

any way to use the used and total values directly?

#

messing with percentage values won't be fun

wicked temple
#

Yeah I have these for each drive sensor.glances_mnt_disk2_free & sensor.glances_mnt_disk2_used

#

They're just numbers in GB

dreamy sinew
#

do you have total size?

#

oh, don't need it

#

just add up free and you're done

#

unless you want percentage and then you'd need to add a bunch of stuff

wicked temple
#

Whatever way is the easiest to implement i'm all for it

dreamy sinew
#

what do you want to see as your end result? GB free or % available?

wicked temple
#

I'm so out of my league at this point haha

#

% would be great

dreamy sinew
#

do you have a total size output for each disk?

wicked temple
#

Actually scratch that, GB free is much better for me

#

I only have those 2 values for each disk

dreamy sinew
#

ah, that's a pain

#

but just add up GB Free and be done with it

#

using the template from above, swap in the _free entities and you'll have your number

#

add a unit of measurement of GB and you're golden

wicked temple
#

Works great! Thanks alot πŸ˜„

bitter atlas
#

@dreamy sinew πŸŽ‰

dreamy sinew
#

Lol

calm kettle
#

I'm having trouble with my template, it worked for a bit but now it doesn't. It is supposed to read the Google calendar and turn off accordingly.

  - condition: template
    value_template: '{% if now().year~''-''~now().month~''-''~now().day~''-''~now().hour~''-''~now().minute~''-''~now().second
      >= state_attr(''calendar.ouachita_hills_academy'',''start_time'') and  now().year~''-''~now().month~''-''~now().day~''-''~now().hour~''-''~now().minute~''-''~now().second
      <= state_attr(''calendar.ouachita_hills_academy'',''end_time'') and is_state_attr(''calendar.ouachita_hills_academy'',''description'',''class
      off'') %}{{false}}{%else%}{{true}}{%endif%}'

Thanks

#

today it should be on but tomorrow it shouldn't. Here is what is in states.
message: Vocational Classes
all_day: true
start_time: 2020-09-16 00:00:00
end_time: 2020-09-17 00:00:00
location:
description: class off
offset_reached: false
friendly_name: Ouachita-Hills-Academy

mighty ledge
#

if you paste that into the template editor it does not work?

#

@calm kettle I'm not sure where you are from either, but today is the 15th for me. And your calendars time's are for tomorrow

calm kettle
#

yes today it should be on. and tomorrow it should be off. The bell is on unless otherwise told not to be.

mighty ledge
#

What is your date today?

calm kettle
#

the problem is that it is not turning off when its supposed to

#

I'm in Arkansas today is the 15th

mighty ledge
#

Ok, well your calendar event says tomorrow

#

start_time: 2020-09-16 00:00:00
end_time: 2020-09-17 00:00:00

#

so it's not your template

calm kettle
#

yes, I'm trying to fix it today so that it will not turn on tomorrow

#

the date for the calendar is correct

#

It's been a problem I've been remedying by just turning off the automation.

mighty ledge
#

calendar entity or your actual calendar outside HA

#

This is what I'm confused about: You say it should be ON today, but the dates on the calendar entity are for tomorrow, and you say the calendar is correct

#

so what's correct

calm kettle
#

that is what it is showing in the states, it always shows the next calendar event.

#

I see the confusion.

#

the bell is always set to turn on

#

everyday

mighty ledge
#

Ok, so it should be OFF today

calm kettle
#

the only thing that stops it is when it checks the calendar to see if it is supposed to be off

#

no, today the bell should be on

#

I'm trying to fix the problem I will have tomorrow.

mighty ledge
#

Ok, so you want to check a day ahead then, but it should be off tomorrow

bitter atlas
#

I just create templat binary with something like is_state_attr('calendar.holidays_in_united_states', 'message', 'New Year\'s Eve' and then use that as a condition.

calm kettle
#

yes

#

I just create templat bools with something like is_state_attr('calendar.holidays_in_united_states', 'message', 'New Year\'s Eve' and then use that as a condition.
@bitter atlas hum... I thought I did...

#
      off'') %}{{false}}{%else%}{{true}}{%endif%}'```
bitter atlas
#

I thought what you posted above was in like an automation or something. plus it's very complex when all your checking is if it's that day

mighty ledge
#

first, you should incorporate

sensor:
  - platform: time_date
    displayed_options:
    - date_time
calm kettle
#

yeah, it happens when you don't know what you are doing....

#

lol

#

I'm still having trouble writing things out correctly lol

#

ok let me give it a shot.

bitter atlas
#

{% if is_state_attr('calendar.ouachita_hills_academy', 'description', 'class off') %} should work in a bool

calm kettle
#

man, messed up and the pi is shutdown. It's booting now it will be a bit.

#

*I

mighty ledge
#

Then use this as your value_template, easier to read:

    value_template: >
      {% set t = state_attr('sensor.date_time', 'timestamp) | timestamp_custom('%Y-%m-%d %H:%M:%S') %}
      {% set start = state_attr(''calendar.ouachita_hills_academy'',''start_time'') %}
      {% set end = state_attr(''calendar.ouachita_hills_academy'',''end_time'') %}
      {% set class_off = is_state_attr(''calendar.ouachita_hills_academy'',''description'',''class off'') %}
      {{ start =< t <= end and class_off }}
#

But that will not check tomorrow, that will only work day of. So if the event's are always shown ahead of time, you'd need to add 24 hours (in seconds) to t

#

which looks like:

    value_template: >
      {% set t = (state_attr('sensor.date_time', 'timestamp)+86400)| timestamp_custom('%Y-%m-%d %H:%M:%S') %}
      {% set start = state_attr(''calendar.ouachita_hills_academy'',''start_time'') %}
      {% set end = state_attr(''calendar.ouachita_hills_academy'',''end_time'') %}
      {% set class_off = is_state_attr(''calendar.ouachita_hills_academy'',''description'',''class off'') %}
      {{ start =< t <= end and class_off }}
calm kettle
#

ok sweet, It's still booting 😩

#

humm.. I may have bigger problems if it doesn't boot...

mighty ledge
#

That will only work if you add sensor.date_time. If you're keeping this a condition and not a template sensor, you don't need sensor.date_time

calm kettle
#

well it's not booting... I'm pretty sure it is because I have a crappie budget SD card. I bought a Samsung card that I was about to image to and now it may be too late. I did save the config, so I'll just use a stock image and upload my config.

#

Thanks for the help, I'll have to come back later and tell you how it went.

inner mesa
#

the good news is that the bell will be off tomorrow πŸ™‚

calm kettle
#

that's true lol

paper hazel
#

Hi, looking for some help. I'm trying to calculated the total time configured per week day configured. If the entity (input_number) is configured for a specific day, it is added a group for that day of the week. How can I loop through the members of the group and sum their values?

dreamy sinew
#

i've seen some tricks but i don't have any groups so i don't remember them

paper hazel
#

Thx! Found a basic example on the forum to print the entity_ids - Will try and build from there.

dreamy sinew
#

it gets tricky if you're trying to do a sensor

paper hazel
#

The idea is to do the calculation at runtime and display the result on a lovelace card

dreamy sinew
#

if you're cool with a button press to do the calculation you're golden

#

homeassistant.update_entity would be the service to call

paper hazel
#

Thank you so much! This is so much more elegant than what I have been busy creating...

dreamy sinew
#

just as long as you're cool with the caveat that it will never update on its own πŸ™‚

#

oh wait

#

{{ [states(x)|float for x in state_attr('group.your_group', 'entity_id')]|sum }}

#

sorry, need to make it a number otherwise it will puke

#

should be able to drop it in the template tester though

brisk temple
#

If I am getting this error Error executing script. Unexpected error for call_service at pos 2: 'entity_id' would service position 2 include only - service or would it be the 3rd - under the sequence?

dreamy sinew
#

.share the full thing please

silent barnBOT
distant plover
#

When I use this under dev tools - templates I get a line shift after each item, but when I add it to an persistent notification automation there is no line shift. Any ideas? {% set names = state_attr('sensor.utilgjengelige_entiteter','names').split(', ') %} {% set ents = state_attr('sensor.utilgjengelige_entiteter','entities').split(', ') %} {% for i in range(names|length) -%} {{ '{} ({})'.format(names[i], ents[i]) }} {% endfor %}

dreamy sinew
#

never messed with it. might be that the notification eats line breaks

distant plover
#

Google says that {{ '\n' -}} should work. Can that be put into the above somehow?

#

{{ '{} ({})'.format(names[i], ents[i]) }} {{ '\n' -}}?

#

Trying it now

dreamy sinew
#
{% set ents = "another, word".split(', ') %}
{% for i in range(names|length) -%}
{{ '{} ({})'.format(names[i], ents[i]) }}{{ '\n' if i != names|length -}}
{% endfor %}```
#

sorry, had to add some dummy values since i don't have those entities

distant plover
#

What's the i != names|length?

dreamy sinew
#

no extra newline at the end of the template

distant plover
#

Ah. Thanks again πŸ™‚

brisk temple
#

here's the two scripts, I am on beta so service is correct (vs service_template)

#

i get the error when i run unpause_outside_cameras

#

and the only input_boolean that is 'on' is input_boolean.camera_frontporch

#

i can manually run enable_frontporch_camera and it works with no errors

#

but the error looks like that's the one it is complaining about

inner mesa
#

what error?

dreamy sinew
#

do you know which one it is complaining about?

brisk temple
#

that's what i was trying to confirm, i am assuming the error Error executing script. Unexpected error for call_service at pos 2: 'entity_id' when i run script.unpause_outside_cameras is refering to the 3rd - service which is the frontporch_camera

inner mesa
#

did you try each of those blocks in devtools -> Temp[lates?

brisk temple
#

yes

#

no errors, and expected results

#

seems to have an issue with the is_state_attr?

#

in the enable_frontporch_camera but manually running that script works

dreamy sinew
#

quote the false

inner mesa
#

I would think not - if it's really a boolean

dreamy sinew
#

it almost never is though

inner mesa
#

I went through that yesterday with someone and it was

#

for sun.sun & rising

#

could be either, I guess

#

still, I would think the result would be the "else" case unexpectedly

brisk temple
#

{{ state_attr('camera.blink_frontporch', 'motion_detected') is boolean }} says True

inner mesa
#

PoPBoX with the skillz

brisk temple
#

let me jump back to 114.4 and see if this isn't a bug

inner mesa
#

aren't you missing the entity_id from homeassistant.update_entity?

#

this seems incomplete:

#
    - service: >
        {% if is_state('input_boolean.camera_mudroom_door', 'on') %}
          script.enable_mudroom_door_camera
        {% else %}
          homeassistant.update_entity
        {% endif %}
brisk temple
#

oh, yes it is

inner mesa
#

the script is just a service, but homeassistant.update_entity is expecting an entity

#

that's a problem twice

#

a choose would work there

brisk temple
#

waiting for my HA to load backup and i'll try with the entity_id added

inner mesa
#

You'll at least need to split it up

brisk temple
#

it all needs to be rewritten, it's highly unreliable

inner mesa
#

it does seem complicated

brisk temple
#

and it was just to bypass having to put in delays waiting for blink to arm/unarm cameras that were already in that state

paper hazel
#

Any idea while this is not working?```
{%- set total_time = 0 -%}
{%- for number in range(1,16,1) %}
{{ total_time + 1 }}
{% endfor %}

#

It just renders '1' - 16 times...

inner mesa
#

what are you expecting?

paper hazel
#

1,2,3,4,5 .... 14,15,16

inner mesa
#

total_time is always 0 + 1

#

you're never updating it

dreamy sinew
#

also namespacing

inner mesa
#

that too

#

always forget the scoping rules

paper hazel
#

hmm... let me read up on that

#

Thank you!

dreamy sinew
#
{%- set ns = namespace(total_time=0) -%}
{%- for number in range(1,16,1) %}
{%- set ns.total_time = ns.total_time + 1 -%}
  {{ ns.total_time }}
{% endfor %}```
#

since += isn't a thing sadly

brisk temple
#

it was the missing entity_ids for hte homeassistant.update_entity, thanks!

dreamy sinew
#

i wonder though

paper hazel
#

Thank you! πŸ™πŸΌ

inner mesa
#

seems weird that the dashes in {%- and -%} are required to avoid extra newlines in the output

#

if I remove them in {%- set ns.total_time = ns.total_time + 1 -%}, I get a bunch of extra newlines from what I would have thought is simply logic

brisk temple
#

isn't it just needed in {{- ns.total_time -}}

inner mesa
#

see, that's what I would have thought

#

try it

dreamy sinew
#

because the logic is evaluated but it still takes space

inner mesa
#

evidently

#

I never ever need or use a dash in my scripts/automations, so I don't know the rules

#

if you look through forum posts from ages ago, they're everywhere

dreamy sinew
#

{{ ",".join(range(1,16,1)|map("string")|list) }}

#

πŸ˜„

#

output: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

bitter atlas
#

now code the answer to the meaning of life

buoyant pine
#
{{ 42 }}
violet oyster
#

yessssss

dreamy sinew
#

i'm not sure how useful that output is, but its there

charred dagger
dreamy sinew
#

lol

charred dagger
#

xkcd 221

violet oyster
#

hahaha

dreamy sinew
#
try:
    answer = self.answer_question("What is the answer to the ultimate question?")
except TimeOutError:
    answer = 42
finally:
    return answer
violet oyster
#

i wish they never made the movie. cheapens such an unbelievable book series

calm kettle
#

Hello I'm back again.
Got an error

Message malformed: invalid template (TemplateSyntaxError: unexpected '%') for dictionary value @ data['condition'][0]['value_template']

#

this is the template

      {% set start = state_attr(''calendar.ouachita_hills_academy'',''start_time'') %}
      {% set end = state_attr(''calendar.ouachita_hills_academy'',''end_time'') %}
      {% set class_off = is_state_attr(''calendar.ouachita_hills_academy'',''description'',''class off'') %}
      {{ start =< t <= end and class_off }}```
violet oyster
#

missing a ' after timestamp

calm kettle
#

πŸ˜†

#

ok

violet oyster
#

also why are there double single quotes on the rest of them

dreamy sinew
#

the UI does garbage like that

violet oyster
#

oh

dreamy sinew
#

its technically correct but really ugly

violet oyster
#

thanks ui, i hate it

calm kettle
#

I'm still really bad at syntax, this code was given to me earlier by a helpful guy on here

#

I'm very much a noob at this and only have an into to programing class as a basis.

dreamy sinew
#

jinja is a bit special

violet oyster
#

its all i've ever known

#

like a poor kid who never realized he was poor

calm kettle
#

Message malformed: invalid template (TemplateSyntaxError: expected token 'end of print statement', got '=') for dictionary value @ data['condition'][0]['value_template']

#

still getting errors...

#
      {% set start = state_attr('calendar.ouachita_hills_academy','start_time') %}
      {% set end = state_attr('calendar.ouachita_hills_academy','end_time') %}
      {% set class_off = is_state_attr('calendar.ouachita_hills_academy','description','class off') %}
      {{ start =< t <= end and class_off }}```
I changed it but might have made it worse
#

may be I need to read up on something. Like yaml for dummies? LOL

dreamy sinew
#

needs to be <=

inner mesa
#

Jinja

calm kettle
#

seems to have liked that.

violet oyster
#

damn missed that one. saw the first error and thought i cracked the case lol

calm kettle
#

Jinja
@inner mesa are you saying Jinja is a good place to start?

dreamy sinew
#

.jinja2 is a good place to start

silent barnBOT
calm kettle
#

Thanks for the help guys, I hope the system works like it should tomorrow.

violet oyster
calm kettle
dreamy sinew
#

the built in filters are where a lot of the power is

#

HA adds a few extras

calm kettle
#

humm... I have a problem now. the automation should work for today but not tomorrow. and now if I set it to go off for today it's not doing it.

#

I think it is because in the states it shows the next event no matter how far in the future.
it says its 'off'
message: Vocational Classes
all_day: true
start_time: 2020-09-16 00:00:00
end_time: 2020-09-17 00:00:00
location:
description: class off
offset_reached: false
friendly_name: Ouachita-Hills-Academy

violet oyster
#

wait. what are you trying to do

calm kettle
#

I have a relay I need to trigger on a schedule, I want it to trigger everyday except when told not to by the calendar.

#

for instance today it should ring

#

tomorrow it should not

#

sorry I said ring but trigger is what I meant. It is for a class bell

bitter atlas
#

you need it to trigger at a specific time only once?

calm kettle
#

repeating every week

#

so the trigger is the time of day and the condition is the calendar

#

if I'm saying that right.

#

everyday if the condition is not met, in this case 'class off' the bell will ring.

violet oyster
#

so, i'm no expert here, but i am wondering about the template syntax with

      {% set class_off = is_state_attr('calendar.ouachita_hills_academy','description','class off') %}

wouldn't that set class_off as 'true' or 'false'? and if so, wouldn't the final line need to condition class_off to be either true or false instead of just reference it?

#

like

      {{ start <= t <= end and class_off=false }}

or something

calm kettle
#

do I need ```
{{false}}{%else%}{{true}}{%endif%}

violet oyster
#

i honestly have no idea if i am right or not, just wondering.

calm kettle
#

I remember I had this problem before.

#

but not sure about the fix

#

at least I think i did.

#

I'm going to have to go. Thanks for the help. I'll come back tomorrow. I need to get my friend who helped me originally to check it out again.

violet oyster
#

yeah, good luck

bitter atlas
#

so the trigger is the time of day and the condition is the calendar
@calm kettle do you have the time set in the calendar? what you posted above was a the whole day

quasi glade
#

https://hastebin.com/fegigudavu.bash
I'm trying to have my I2C configuration set up in the device_base.yaml and have it set the SDA and SCL pins according to what platform I'm using - this conditional shows "{% if ESP32 == ESP32 %} in ESPHome, but it doesn't return the right pins. Isn't it possible to return the pin depending on the platform?

calm kettle
#

@calm kettle do you have the time set in the calendar? what you posted above was a the whole day
@bitter atlas Yes it is set for the whole day, the trigger is time.

#

I think I found a way to make it work. When the calendar event is active/on-going the state of the calendar is on when there are no events the calendar state is off.

#
      {% is state = state('calendar.ouachita_hills_academy') %}

      {% set class_off = is_state_attr('calendar.ouachita_hills_academy','description','class off') %}
      {{ state= on and class_off }}```
#

I don't think that is correct but may be someone could help me fix it.

#

condition is the calendar

#

trigger is time of day.

bitter atlas
#

@calm kettle petro's code was accurate and gave you more control over fine tuning the template but if you don't care about the calendars event time and just want it to ring True for the entire day and use a separate trigger for time something like this would work

{% is_state('calendar.ouachita_hills_academy', 'on') and is_state_attr('calendar.ouachita_hills_academy','description','class off') %}
calm kettle
#

awesome, thanks.

#

Tried to find how to specify state because it didn't like is_state, I couldn't find what to call it.

bitter atlas
#

is_state is a true/false response

woven cedar
#

how should my template sensor look to show percetage value of battery level which is populated as voltage values in range of 4.2-3.0 ?

bitter atlas
woven cedar
#

probably, ill look into it

#

ok but how did he get that {{ ((states('sensor.stacja_pogodowa_bateria')|float-3.0)/**0.0252**)|round(1) }}

#

0.0252

bitter atlas
#

maths more than likely

woven cedar
#

well that sucks then πŸ˜„

dusky bane
#

hi all! i have a litlle syntax problem i'm sure someone have a quick answer to it :

    action:
        - service: notify.mobile_app_iphone_de_paul
          data_template:
             message:   "mdi:chili-mild {{ states('sensor.vapor_deficit') }}, mdi:thermometer {{ states('sensor.thermohygro3_temperature') }}, mdi:water-percent {{states('sensor.thermohygro3_humidity') }}"

In the notification i don't see the icons, how can i correct this ?

bitter atlas
#

whatever device you are sending that too dosen't know what the heck mdi:some-icon-is

calm kettle
#

is_state is a true/false response
@bitter atlas
Not sure if I follow you, if it is a true/false response how should I write it?

bitter atlas
#

@calm kettle if you want the actual state of an entity you gotta use states not is_state

calm kettle
#

Oh ok, so it's state.state, I'm going to try it

dusky bane
#

@bitter atlas okay thx

calm kettle
#

TemplateSyntaxError: Encountered unknown tag 'states'

bitter atlas
#

@calm kettle I don't know what you are trying to do, the example I gave you is how it's done

calm kettle
#

it doesn't except it. I'm trying different things to try to get it to work

bitter atlas
#

where are you putting this code?

calm kettle
#

(TemplateSyntaxError: Encountered unknown tag 'is_state'.)

#

in the template

bitter atlas
#

what template? in an automation? script? as a template sensor? template binary? where

calm kettle
#

automation under conditions

#

and I changed the condition type to template.

bitter atlas
#

@calm kettle ```
{{ is_state('calendar.ouachita_hills_academy', 'on') and is_state_attr('calendar.ouachita_hills_academy','description','class off') }}

calm kettle
#

I see, thanks for the change. the way you wrote it the first time was for where?

bitter atlas
#

for a template sensor or binary

astral wren
#

unable to find reference for this issue. Id like this ``` - platform: template
sensors:
spacex_next_rocket:
friendly_name: 'Next Rocket'
value_template: '{{ state_attr("sensor.spacex","rocket")==("rocket_name") }}'

spacex_next_rocket:
  friendly_name: 'Next Rocket'
  value_template: '{{ states.sensor.spacex.attributes["rocket"]["rocket_name"] }}'``` to evaluate to the same . ie... "Rocket_Name"  the first example is my attempt to convert the second example to the newer method that avoids (states.sensor.some_sensor.state) method because it causes error if the states ever returns as unavailable
#

currently it evaluates like this ``` - platform: template
sensors:
spacex_next_rocket:
friendly_name: 'Next Rocket'
value_template: 'False'

spacex_next_rocket:
  friendly_name: 'Next Rocket'
  value_template: 'Falcon 9' ```
#

"rocket_name" is an attribute of the attribute "rocket"

#

Of the sensor "sensor.spacex"

#

"rocket" is a list of other attributes

calm kettle
#

for a template sensor or binary
@bitter atlas

Thanks for helping a noob out

wheat cargo
#

hi, I have a history_stats sensor that is counting the time a sensor is on. The result is a sensor with a number of hours like 8.33 . What's the right way to convert that to a formatted time length? (like '8:20' or '8h 20min')

#

I guess I can do some calculations to generate that formatted string, but I'm sure there's an easier way

astral wren
#

@wheat cargo something similar to this perhaps

#

@wheat cargo - platform: template sensors: history_stats_friendly: friendly_name: 'Stats History Converted Time ' value_template: '{{ states("sensor.history_stats") | int | timestamp_custom("%H:%M %Z")}}'

#

@wheat cargo that would basically leave thew other sensor unchanged and create a new sensor called history_stats_friendly that converts the original sensors time to a friendly view. ALSO remove the %Z if you dont need to see the time zone at the end . (ie.... 8:20 EDT. )

astral wren
#

More like this perhaps@wheat cargo
now = hass.states.get('sensor.time').last_changed.timestamp measureStartTime = float(hass.states.get('var.ac%s_fan_measure_start_time' %(ac)).state) logger.info('LSX: now=%s start=%s', now, measureStartTime) diff = now - measureStartTime logger.info('LSX: diff=%s', now)

wheat cargo
#

@astral wren: that's python, do you mean I should use a python script?

#

@astral wren: just in case it's useful for someone else, I did it with a variation of your first idea:

value_template: '{{ states("sensor.history_stats") | float | multiply(3600) | timestamp_custom("%H:%M", false) }}'
astral wren
#

Nice I especially like the | float | multiply(3600) |part

dreamy sinew
#

using all filters enforces order of operations, nice one

calm kettle
#

so I don't know what I did, but now in my log book it is constantly turning off my automation.

#

any ideas?

  - at: '12:10:00'
    platform: time
  condition:
  - condition: template
    value_template: '{{ is_state(''calendar.ouachita_hills_academy'', ''on'') and
      is_state_attr(''calendar.ouachita_hills_academy'', ''description'', ''wed'')
      }}'
  action:
  - data:
      entity_id: switch.relay_01
    service: switch.turn_on
inner mesa
#

there's nothing there that would cause your automation to be disabled, but your indentation is wrong

calm kettle
#

it is?

inner mesa
#

trigger:, condition:, and action: should be aligned

dreamy sinew
#

probably a paste error

inner mesa
#

could be

#

in any case, the problem isn't in that automation

calm kettle
#

I can't show you screenshots can I ?

inner mesa
#

if it's text, no

dreamy sinew
#

.images if you must

silent barnBOT
#

Please use imgur or other image sharing web sites, and share the link here.

dreamy sinew
#

but if its a picture of text we're gonna slap you

calm kettle
#

well the automation isn't working either

dreamy sinew
#

one offset like that reads to me as a copy-paste error as there should be a key above that that has been ommitted

calm kettle
#

yeah they are all lined up .

inner mesa
#

other than that, I don't see anything fishy in that automation

#

that and the funky double quotes

calm kettle
#
  condition:
  - condition: template
    value_template: '{{ is_state(''calendar.ouachita_hills_academy'', ''on'') and
      is_state_attr(''calendar.ouachita_hills_academy'',''description'', ''wed'')
      }}'

this is the part that isn't working, everything before the "and" works but not the description part

inner mesa
#

if that's actually on a separate line, then that would be a problem

#

I think?

#

I'm suspicious of anything that comes out of the UI editor

calm kettle
#

it's not

inner mesa
#

then what does devtools -> States say for calendar.ouachita_hills_academy in the attributes section?

calm kettle
#

message: Vocational Classes
all_day: true
start_time: 2020-09-16 00:00:00
end_time: 2020-09-17 00:00:00
location:
description:
wed
offset_reached: false
friendly_name: Ouachita-Hills-Academy

inner mesa
#

weird that "wed" is on the next line

calm kettle
#

yeah that's what I thought

#

I went to the calendar and erased all spaces

inner mesa
#

must have a newline in there or something

calm kettle
#

but may be it hasn't updated yet?

inner mesa
#

anyway, you can play around with the template in devtools -> Templates

calm kettle
#

just went to the calendar and apparently it adds a new line automatically

#

because I just got rid of it twice and it added it back

inner mesa
#

you can also something like 'wed' in state_attr("calendar.ouachita_hills_academy","description")