Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


peejayw

1757 posts

Uber Geek


#310513 26-Oct-2023 17:00
Send private message

I am trying to copy and paste part of a config.yaml file into a new file. This is the clip.

 

#TempDiff
######
  - platform: template
    sensors:
      temperature_difference:
       friendly_name: "Temperature Difference"
       unit_of_measurement: '°C'
       value_template: >
             {{ ( states('sensor.lumi_lumi_weather_temperature')|float(0) - states('sensor.lumi_lumi_weather_b083df07_temperature')|float(0) )|round(2) }}

 

 

 

When I paste it in I get these errors

 

 

#TempDiff

 

######

 

  - platform: template  bad indentation of a mapping entry

 

    sensors:

 

      temperature_difference: can not read a block mapping entry; a multiline key may not be an implicit key

 

       friendly_name: "Temperature Difference"

 

       unit_of_measurement: '°C'

 

       value_template: >

 

             {{ ( states('sensor.lumi_lumi_weather_temperature')|float(0) - states('sensor.lumi_lumi_weather_b083df07_temperature')|float(0) )|round(2) }}

 

 

 

 

What am I doing wrong here?





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Create new topic
nzkc
1360 posts

Uber Geek


  #3152445 26-Oct-2023 17:36
Send private message

Probably need to see the surrounding fragments of yaml since its complaining about indentation. Could be the previous/next fragments change the indentation you need.


 
 
 

Backblaze Unlimited Backup. World’s easiest cloud backup. Get peace of mind knowing your files are backed up securely in the cloud (affiliate link).
marpada
450 posts

Ultimate Geek


  #3152446 26-Oct-2023 17:41
Send private message

Hard to say as the forum software might screw the format, but the indentation below temperature_difference might be wrong, make sure it's at least 2 spaces. Does it validate if you paste the snippet on https://codebeautify.org/yaml-parser-online. ?


peejayw

1757 posts

Uber Geek


  #3152447 26-Oct-2023 17:59
Send private message

This is what it looks like

 

 

 





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.




peejayw

1757 posts

Uber Geek


  #3152448 26-Oct-2023 18:00
Send private message

It validates in the online parser.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


marpada
450 posts

Ultimate Geek


  #3152455 26-Oct-2023 18:42
Send private message

Indentation is important in yaml, keep it consistent at 2 spaces


  #3152456 26-Oct-2023 18:44
Send private message

You’re probably missing
sensor:
Above your
- template

  #3152457 26-Oct-2023 18:52
Send private message

Template sensors changed a while ago
So it might be
template:
-sensor:
-name: “sensor name”
unit_of_measurement: “•c”
Etc….



bigreddog
167 posts

Master Geek

Subscriber

  #3152562 27-Oct-2023 10:42
Send private message

The first line "-platform: template should have no indentation. 

 

Move the whole lot back to the left (select the text and shift tab):

 

 

 


peejayw

1757 posts

Uber Geek


  #3152580 27-Oct-2023 11:41
Send private message

Thanks for that, think I am getting close. This is what I am getting now.

 





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


eluSiveNZ
180 posts

Master Geek


  #3152641 27-Oct-2023 12:17
Send private message

peejayw:

 

Thanks for that, think I am getting close. This is what I am getting now.

 

 

 

I think you are using quite old config. Also i dont believe "sensorS" is correct. should it be "sensor"

 

Regardless, you can set this up in the UI quite easily - Settings\Devices & Services\Helpers - Create Helper = Template \ Template a sensor

 

Put your details from the yaml here, State Template will be your value template - if this is all correct it will show you a preview in the same window


peejayw

1757 posts

Uber Geek


  #3152663 27-Oct-2023 12:50
Send private message

Thanks, that looks interesting, will give it a go.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1757 posts

Uber Geek


  #3152719 27-Oct-2023 13:05
Send private message

OK, I set up a template using the data from my old file. This used to work in my previous HA config to subtract the temperature of one sensor from another to produce the difference between the two.

 

In the template sensor I have Unit of measurement as degrees C, Device Class as Temperature and State Class as Measurement.

 

The current values for those sensors are 17.4 and 16.9 respectively so I should get a result of 0.5 but instead I get 17.4.

 

Can you spot my error?

 

Many thanks.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1757 posts

Uber Geek


  #3152730 27-Oct-2023 13:43
Send private message

Never mind, typing error on my part.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Create new topic





News and reviews »

One New Zealand Extends 3G Switch-off Date
Posted 11-Apr-2024 08:56


Amazon Echo Hub Review
Posted 10-Apr-2024 18:57


Epson Launches New Versatile A4 Desktop Scanners
Posted 10-Apr-2024 15:31


Motorola Mobility Launches New Android Phones in New Zealand
Posted 10-Apr-2024 14:59


Logitech G Unveils the PRO X 60 Gaming Keyboard
Posted 9-Apr-2024 19:01


Logitech Unveils Signature Slim Keyboard and Combo
Posted 9-Apr-2024 13:33


ExpressVPN Launches Aircove Go Portable Router With Built-in VPN
Posted 26-Mar-2024 21:25


Shure MoveMic Review
Posted 25-Mar-2024 12:47


reMarkable 2 Launches at JB Hi-Fi New Zealand
Posted 20-Mar-2024 08:36


Samsung Galaxy S24 Ultra review
Posted 19-Mar-2024 11:37


Google Nest Wifi Pro Review
Posted 16-Mar-2024 11:28


Samsung Galaxy A55 5G and Galaxy A35 5G
Posted 12-Mar-2024 12:41


Cricut EasyPress Mini Zen Blue launches at Spotlight New Zealand
Posted 12-Mar-2024 12:32


Logitech Introduces MX Brio Webcam
Posted 12-Mar-2024 12:24


HP Unveils Broadest Consumer Portfolio of AI-Enhanced Laptops
Posted 3-Mar-2024 18:09









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.







Backblaze unlimited backup