jacoscar
(Jacopo)
October 10, 2020, 11:32am
1
I have an EV charger that uses MQTT to publish its state on a MQTT topic
For example
1 = vehicle connected
2 = vehicle charging
3 = vehicle disconnected
How can I translate the numbers (1,2,3) into meaningful text that I can show in the dashboard?
1 Like
Use a value template in your sensor configuration where you map the numbers to the desired values. Here an example how it could look like:
value_template: >
{% set map = {
'1': 'vehicle connected',
'2': 'vehicle charging',
'3': 'vehicle disconnected'
} %}
{{ map[value] if value in map else 'error' }}
fabaff
(Fabian Affolter)
October 10, 2020, 11:48am
3
jacoscar
(Jacopo)
October 10, 2020, 12:08pm
4
I get the error
missed comma between flow collection entries at line 605, column 6:
{% set map = {
^
Can you show the complete sensor code?
jacoscar
(Jacopo)
October 10, 2020, 12:20pm
6
I think I need a comma before the last line
No, I don’t think so,can you share the complete sensor code please?
jacoscar
(Jacopo)
October 10, 2020, 12:23pm
8
It was an indentation problem, this works, thanks!
- platform: mqtt
name: "Prism stato della porta di ricarica"
state_topic: "prism/1/state"
value_template: >
{% set map = {
'1': 'nessun veicolo connesso',
'2': 'veicolo connesso, in attesa di ricaricare',
'3': 'veicolo in carica',
'4': 'carica in pausa'
} %}
{{ map[value] if value in map else 'error' }}
2 Likes
P91T
(Paolo)
December 29, 2020, 4:53pm
9
Hi @jacoscar , I also want to integrate the Cartender Prism inside home assistant, could you share your code?
jacoscar
(Jacopo)
January 12, 2021, 7:31pm
10
@P91T here it is
- platform: mqtt
name: "Prism hello"
state_topic: "prism/hello"
- platform: mqtt
name: "Prism stato"
state_topic: "prism/1/state"
value_template: >
{% set map = {
'1': 'nessun veicolo connesso',
'2': 'veicolo connesso, in attesa di ricaricare',
'3': 'veicolo in carica',
'4': 'carica in pausa'
} %}
{{ map[value] if value in map else 'error' }}
- platform: mqtt
name: "Prism corrente"
state_topic: "prism/1/amp"
unit_of_measurement: 'mA'
- platform: mqtt
name: "Prism wh sessione"
state_topic: "prism/1/wh"
unit_of_measurement: 'Wh'
- platform: mqtt
name: "Prism corrente pilotata dall’auto"
state_topic: "prism/1/pilot"
unit_of_measurement: 'A'
- platform: mqtt
name: "Prism user_amp"
state_topic: "prism/1/user_amp"
unit_of_measurement: 'A'
- platform: mqtt
name: "Prism tensione attuale"
state_topic: "prism/1/volt"
unit_of_measurement: 'V'
- platform: mqtt
name: "Prism potenza"
state_topic: "prism/1/w"
unit_of_measurement: 'W'
- platform: mqtt
name: "Prism energia totale"
state_topic: "prism/1/wh_total"
unit_of_measurement: 'Wh'
- platform: mqtt
name: "Prism durata sessione"
state_topic: "prism/1/session_time"
unit_of_measurement: 's'
- platform: mqtt
name: "Prism error"
state_topic: "prism/1/error"
- platform: mqtt
name: "Prism mode"
state_topic: "prism/1/mode"
value_template: >
{% set map = {
'1': 'Solare',
'2': 'Normale',
'3': 'Pausa',
'7': 'Pausa causata da autolimit'
} %}
{{ map[value] if value in map else 'error' }}
- platform: mqtt
name: "Prism temperatura"
state_topic: "prism/0/info/temperature/cover"
unit_of_measurement: '°C'
- platform: mqtt
name: "Prism Tocco"
state_topic: "prism/1/input/touch"
- platform: mqtt
name: "Prism Bussata"
state_topic: "prism/0/input/knock"
- platform: mqtt
name: "Prism power grid"
state_topic: "prism/energy_data/power_grid"
unit_of_measurement: 'W'
` ` `
2 Likes
P91T
(Paolo)
January 13, 2021, 10:32am
11
Thank you so much!
do you like to start writing an integration so other users could add prism to their hass instace with the simplicity of downloading a custom component?
I’m not very experienced but there is a lot of documentation and I think we could try!
Don’t wanna sound rude, but if OP doesn’t even know how to use the mapping solution I provided, I doubt he has the skills to create a cudtom component.
jacoscar
(Jacopo)
January 13, 2021, 11:01am
13
You’re right, and I don’t have time
Klagio
(Klagio)
January 24, 2021, 8:58pm
14
I am receiving a PRISM soon, any recommendations on how to integrate it
Klagio
(Klagio)
February 13, 2021, 10:20pm
15
Hi, how did you implement MQTT input and MQTT command from PRISM?