They have an email address I can contact, so I’ll try that and report back if I hear anything
I am trying to convert the maintenance values, which are displayed in seconds, to hours for my Roborock.
In the customize.yaml I added the following code:
sensor.roborock_main_brush_left:
value_template: "{{ states('sensor.roborock_main_brush_left') | float / 3600) }}"
Unfortunately, the sensor still displays the value in seconds. Anyone have a tip on what I’m doing wrong?
You cannot add templates to customize.yaml. You have to make a new template sensor (using the documents to properly format it), and use that template.
Oh sorry, beginner’s mistake I’ll start a new attempt tomorrow. Thank you
Hi guys. Thanks for your great work!.
I’m having a small issue with this sensor:
- platform: mqtt
name: "Último Orquideas"
state_topic: ultimo/orquideas
icon: mdi:calendar-clock
value_template: '{{ value | int | timestamp_custom("%a %d %h %H:%M") }}'
The sensor work as is supposed but the value is in English and I would like it to be in Spanish.
I need it to be “Vie 11 Feb 03:59”
as Friday = Viernes
Any Ideas?
Thanks a lot in advance
If your system knows what the locale is correctly then it should convert it automatically.
however if you can’t figure out why it’s not working that way then the only other way I know is to convert using a map:
{% set day_map = {'Mon':'Lunes', 'Tue':'Martes', 'Wed':'Miercoles', 'Thu':'Jueves', 'Fri':'Viernes', 'Sat':'Sabado', 'Sun':'Domingo'} %}
{% set day = value | int | timestamp_custom("%a") %}
{{ day_map[day] ~ ' ' ~ value | int | timestamp_custom("%d %h %H:%M") }}
Change the mapped values to whatever you want to show.
@finity Thanks for the support!!
I thought it should do it automatically… but it isn’t.
I don’t know what I’m doing wrong.
I wrote it like this:
- platform: mqtt
name: "Último Plantas"
state_topic: ultimo/plantas
icon: mdi:calendar-clock
value_template:
{% set day_map = {'Mon':'Lunes', 'Tue':'Martes', 'Wed':'Miercoles', 'Thu':'Jueves', 'Fri':'Viernes', 'Sat':'Sabado', 'Sun':'Domingo'} %}
{% set day = value | int | timestamp_custom("%a") %}
{{ day_map[day] ~ ' ' ~ value | int | timestamp_custom("%d %h %H:%M") }}
and I’m getting this in the "check configuration button:
Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
in "/config/configuration.yaml", line 38, column 9
Line 38 is {% set day_map ...
any ideas?
You need a multi-line quote symbol (>
or |
) between “value_template” and your template:
- platform: mqtt
name: "Último Plantas"
state_topic: ultimo/plantas
icon: mdi:calendar-clock
value_template: >
{% set day_map = {'Mon':'Lunes', 'Tue':'Martes', 'Wed':'Miercoles', 'Thu':'Jueves', 'Fri':'Viernes', 'Sat':'Sabado', 'Sun':'Domingo'} %}
{% set day = value | int | timestamp_custom("%a") %}
{{ day_map[day] ~ ' ' ~ value | int | timestamp_custom("%d %h %H:%M") }}
Thanks for the support!
I found that if I add anything, meanind, a . (dot), a letter, / or \ the string works, but it add that symbol.
If I add a space, or a ’ or " the string doesn’t work.
This example is with '( 'at the beginning and ‘)’ at the end (just for symetry)
value_template:
({% set day_map = {'Mon':'Lun', 'Tue':'Mar', 'Wed':'Mie', 'Thu':'Jue', 'Fri':'Vie', 'Sat':'Sáb', 'Sun':'Dom'} %}
{% set day = value | int | timestamp_custom("%a") %}
{{ day_map[day] ~ ' ' ~ value | int | timestamp_custom("%d %h %H:%M") }})
The result:
I would prefer avoiding the added symbols, but I can live with them hahaha-
Thaks again!
did you see the suggestion (i.e. solution) posted above by @Didgeridrew?
you need to add the “>” symbol after “value_template:” and it should work.
value_template: >
{% set day_map = {'Mon':'Lun', 'Tue':'Mar', 'Wed':'Mie', 'Thu':'Jue', 'Fri':'Vie', 'Sat':'Sáb', 'Sun':'Dom'} %}
{% set day = value | int | timestamp_custom("%a") %}
{{ day_map[day] ~ ' ' ~ value | int | timestamp_custom("%d %h %H:%M") }}
@finity you were right!! the “>” was the missing piece.
I read the @Didgeridrew suggestion, but, as I’m a ‘hardware guy’ I googled ‘python multi-line quote symbol’ and couldn’t find anything useful
hahaha
thank you both for the excellent support!
have a nice weekend!
Hi all, I am not at all good with templates but I’m trying to use one in a Markdown card to extract the date only from a timestamp, but don’t really know how to do it. Wondering if someone can please help me.
type: markdown
content: >-
**ON THE WAY:**
{% for package in
states.sensor.seventeentrack_packages_in_transit.attributes.packages %} **{{
package.friendly_name }}:** Last tracked on {{ package.timestamp }} {{
package.info_text }}.
{% endfor %}
In the above I’d like the timestamp to only show the date, in the format dd-mm-yy. Could someone please show me how this is done, if it is actually possible?
assuming “package.timestamp” returns a valid timestamp it should be:
{{ package.timestamp | timestamp_custom("%d %h %Y") }}
I think it should be:
{{ package.timestamp | timestamp_custom("%d-%m-%y") }}
oops! you’re right.
I was playing around with another template and posted the wrong thing.
thanks for the correction.
Hey there,
Probably you can help me. I have no idea what I am doing wrong. I am trying to get m GameDay sensor right (which I did with this tutorial Create an "Upcoming Sports Game" card with Google Calendar) I was already writing down my request in this group but no one could help me
I used the sensor configuration everyone else has but it shows not what it’s supposed to. It should be like "next Game Saturday 26th at 15.30 but instead it’s formatted terribly
Thats my code
#Eintrachts Next Up Date
- platform: template
sensors:
eintracht_date:
entity_id: calendar.eintracht_frankfurt_spielplan_profimannschaft
friendly_name: Eintrachts next game
value_template: >-
{% if is_state('calendar.eintracht_frankfurt_spielplan_profimannschaft', 'on') %}
Playing Now
{% else %}
{% set st = state_attr('calendar.eintracht_frankfurt_spielplan_profimannschaft', 'start_time') %}
{% if st != None %}
{{ as_timestamp(st) | timestamp_custom("%A, %b %d at %-I:%M %p") }}
{% else %}
No games scheduled
{% endif %}
{% endif %}
#Eintrachts Next Opponent
- platform: template
sensors:
eintrachts_opponent:
entity_id: calendar.eintracht_frankfurt_spielplan_profimannschaft
friendly_name: Eintrachts Next Opponent
value_template: >-
{{ states.calendar.eintracht_frankfurt_spielplan_profimannschaft.attributes.message }}
What does the lovelace card config look like?
The card code looks like this
title: null
type: custom:vertical-stack-in-card
cards:
- type: entities
entities:
- type: custom:template-entity-row
entity: calendar.eintracht_frankfurt_spielplan_profimannschaft
image: /local/icons/Eintracht.png
name: Next Game
secondary: >-
{{states.calendar.eintracht_frankfurt_spielplan_profimannschaft.attributes.message
}}
state: >-
{{states.calendar.eintracht_frankfurt_spielplan_profimannschaft.attributes.start_time
}}
styles:
card:
- font-size: 5px
The way it’s displayed is because you are using the original calendar information instead of the statre of the sensor you created.
try replacing the state line in the card with this:
state: "{{states('sensor.eintracht_date') }}"
THANK YOU SO MUCH! That fully helped and saved my Day