-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprism_solar.yaml
142 lines (131 loc) · 4.5 KB
/
prism_solar.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# prism_solar.yaml
#
# Copyright (C) 2022-2024 Daniele Bochicchio, All Rights Reserved
# For updates see https://github.com/dbochicchio/reactor-mqtt-contrib
#
# *** IMPORTANT ***
# Every time you update the files, a restart is needed.
---
templates:
# prism_solar: charger
prism_solar_charger:
type: ValueSensor
capabilities: ["ev_charger", "power_switch", "toggle", "power_sensor", "energy_sensor", "voltage_sensor", "current_sensor"]
primary_attribute: ev_charger.state
requires: [topic, channel]
description: "Prism Solar EV Charger device to handle the commands and get the current status"
events:
# power_sensor
"%topic%/%channel%/w":
"power_sensor.value":
expr: "float(payload)"
"power_sensor.units": "W"
"x_mqtt_device.online": true
# current_sensor
"%topic%/%channel%/amp":
"current_sensor.value":
expr: "float(payload) / 1000"
"current_sensor.units": "A"
"x_mqtt_device.online": true
# voltage_sensor
"%topic%/%channel%/volt":
"voltage_sensor.value":
expr: "float(payload)"
"voltage_sensor.units": "V"
"x_mqtt_device.online": true
# energy_sensor
"%topic%/%channel%/wh_total":
"energy_sensor.value":
expr: "round(float(payload) * 0.001, 4)" # 1 Wh = 0.001 kWh - value * 0.001
"energy_sensor.units": "KWH"
"x_mqtt_device.online": true
# ev_charger
"%topic%/%channel%/state":
"ev_charger.state":
expr: >
payload == '1' ? 'not connected' :
payload == '2' || entity.attributes.ev_charger.mode == 3 ? 'ready' :
payload == '3' ? 'charging' :
entity.attributes.ev_charger.mode == 7 ? 'limited charging' :
'suspended'
"ev_charger.operating_state":
expr: >
payload == '3' ? 'charge' :
'standby'
"power_switch.state":
expr: "payload == '2'"
"x_mqtt_device.online": true
"%topic%/%channel%/mode":
"ev_charger.mode":
expr: "int(payload)"
"ev_charger.schedule":
expr: >
payload == '1' ? 'solar' :
'normal'
"x_mqtt_device.online": true
"%topic%/%channel%/error":
"ev_charger.error":
expr: "int(payload)"
"ev_charger.state":
if_expr: "float(payload) != 0"
expr: "fault"
type: "raw"
"x_mqtt_device.online": true
"%topic%/%channel%/session_time":
"ev_charger.duration":
expr: "int(payload) * 1000" # from sec to millisecs
"x_mqtt_device.online": true
actions:
power_switch:
"on":
topic: "%topic%/%channel%/command/set_mode"
payload: "2" #normal
"off":
topic: "%topic%/%channel%/command/set_mode"
payload: "3" #pause
"set":
topic: "%topic%/%channel%/command/set_mode"
payload:
expr: "parameters.state ? '2' : '3'"
ev_charger:
"set_current":
topic: "%topic%/%channel%/command/set_current_limit"
payload:
expr: "float(parameters.limit)"
"set_operating_mode":
topic: "%topic%/%channel%/command/set_mode"
payload:
expr: "parameters.mode == 'charge' ? '2' : '1'"
"set_schedule":
topic: "%topic%/%channel%/command/set_mode"
payload:
expr: >
entity.attributes.ev_charger.mode != '3' ?
(parameters.mode == 'solar' ? '1' : '2') :
'3'
# prism_solar: current session
prism_solar_session:
type: ValueSensor
capabilities: ["power_sensor", "energy_sensor", "current_sensor"]
primary_attribute: power_sensor.value
requires: [topic, channel]
description: "Prism Solar EV Charger device to handle the charging session"
events:
# power_sensor
"%topic%/%channel%/w":
"power_sensor.value":
expr: "float(payload)"
"power_sensor.units": "W"
"x_mqtt_device.online": true
# energy_sensor
"%topic%/%channel%/wh":
"energy_sensor.value":
expr: "round(float(payload) * 0.001, 4)" # 1 Wh = 0.001 kWh - value * 0.001
"energy_sensor.units": "KWH"
"x_mqtt_device.online": true
# current_sensor
"%topic%/%channel%/user_amp":
"current_sensor.value":
expr: "float(payload)"
"current_sensor.units": "A"
"x_mqtt_device.online": true