Esphome p1meter victron version » Geschiedenis » Versie 1
Micha Kersloot, 27-06-2023 22:34
| 1 | 1 | Micha Kersloot | h1. Esphome p1meter victron version |
|---|---|---|---|
| 2 | |||
| 3 | <pre> |
||
| 4 | substitutions: |
||
| 5 | name: p1meter |
||
| 6 | friendly_name: p1meter |
||
| 7 | |||
| 8 | |||
| 9 | esphome: |
||
| 10 | name: ${name} |
||
| 11 | friendly_name: ${friendly_name} |
||
| 12 | |||
| 13 | #esp8266: |
||
| 14 | # board: esp01_1m |
||
| 15 | # |
||
| 16 | |||
| 17 | esp32: |
||
| 18 | board: ttgo-t7-v13-mini32 |
||
| 19 | framework: |
||
| 20 | type: arduino |
||
| 21 | |||
| 22 | # Enable logging |
||
| 23 | logger: |
||
| 24 | # Serial logging is disabled by setting the logger baud rate to 0. |
||
| 25 | # Otherwise the logger will occupy the hardware UART, making it unavailable |
||
| 26 | # for receiving smart meter data on pin D7 (GPIO13). |
||
| 27 | baud_rate: 0 |
||
| 28 | |||
| 29 | # Enable Home Assistant API |
||
| 30 | api: |
||
| 31 | encryption: |
||
| 32 | key: "qf1fx8kUj0uTiCK59UTTZalztwe8G1uZpOosMvvrV4E=" |
||
| 33 | |||
| 34 | ota: |
||
| 35 | password: "71b4ad566e816a7f8acb70e75ab94b21" |
||
| 36 | |||
| 37 | wifi: |
||
| 38 | ssid: !secret wifi_ssid |
||
| 39 | password: !secret wifi_password |
||
| 40 | |||
| 41 | # Enable fallback hotspot (captive portal) in case wifi connection fails |
||
| 42 | ap: |
||
| 43 | ssid: "P1Meter Fallback Hotspot" |
||
| 44 | password: "YPlPB0mxRpxD" |
||
| 45 | |||
| 46 | captive_portal: |
||
| 47 | |||
| 48 | uart: |
||
| 49 | id: uart_bus |
||
| 50 | rx_pin: |
||
| 51 | # number: 3 |
||
| 52 | number: GPIO16 |
||
| 53 | inverted: true |
||
| 54 | baud_rate: 115200 |
||
| 55 | rx_buffer_size: 1700 |
||
| 56 | |||
| 57 | dsmr: |
||
| 58 | request_pin: GPIO19 |
||
| 59 | |||
| 60 | globals: |
||
| 61 | - id: portal_id |
||
| 62 | type: std::string |
||
| 63 | restore_value: no |
||
| 64 | initial_value: '"<not set>"' |
||
| 65 | - id: device_instance |
||
| 66 | type: std::string |
||
| 67 | restore_value: no |
||
| 68 | initial_value: '"<not set>"' |
||
| 69 | |||
| 70 | mqtt: |
||
| 71 | broker: venus |
||
| 72 | discovery: false |
||
| 73 | birth_message: |
||
| 74 | topic: device/p1mqtt/Status |
||
| 75 | payload: "{ \"clientId\": \"p1mqtt\", \"connected\": 1, \"version\": \"v1.0\", \"services\": {\"meter1\": \"grid\"} }" |
||
| 76 | will_message: |
||
| 77 | topic: device/p1mqtt/Status |
||
| 78 | payload: "{ \"clientId\": \"p1mqtt\", \"connected\": 0, \"services\": {\"meter1\": \"grid\"} }" |
||
| 79 | on_json_message: |
||
| 80 | topic: device/p1mqtt/DBus |
||
| 81 | then: |
||
| 82 | - lambda: |- |
||
| 83 | id(portal_id) = x["portalId"].as<std::string>(); |
||
| 84 | id(device_instance) = x["deviceInstance"]["meter1"].as<std::string>(); |
||
| 85 | - mqtt.publish_json: |
||
| 86 | topic: !lambda |- |
||
| 87 | return str_sprintf("W/%s/grid/%s/CustomName", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 88 | payload: |- |
||
| 89 | root["value"] = "P1-MQTT Meter"; |
||
| 90 | - mqtt.publish_json: |
||
| 91 | topic: !lambda |- |
||
| 92 | return str_sprintf("W/%s/grid/%s/Role", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 93 | payload: |- |
||
| 94 | root["value"] = "grid"; |
||
| 95 | |||
| 96 | sensor: |
||
| 97 | - platform: dsmr |
||
| 98 | energy_delivered_tariff1: |
||
| 99 | name: Energy Delivered Tariff 1 |
||
| 100 | id: energy_delivered_t1 |
||
| 101 | state_class: total_increasing |
||
| 102 | energy_delivered_tariff2: |
||
| 103 | name: Energy Delivered Tariff 2 |
||
| 104 | id: energy_delivered_t2 |
||
| 105 | state_class: total_increasing |
||
| 106 | energy_returned_tariff1: |
||
| 107 | name: Energy Returned Tariff 1 |
||
| 108 | id: energy_returned_t1 |
||
| 109 | energy_returned_tariff2: |
||
| 110 | name: Energy Returned Tariff 2 |
||
| 111 | id: energy_returned_t2 |
||
| 112 | power_delivered: |
||
| 113 | name: Power Consumed |
||
| 114 | id: power_consumed |
||
| 115 | power_returned: |
||
| 116 | name: Power Returned |
||
| 117 | id: power_returned |
||
| 118 | electricity_failures: |
||
| 119 | name: Electricity Failures |
||
| 120 | electricity_long_failures: |
||
| 121 | name: Electricity Long Failures |
||
| 122 | voltage_l1: |
||
| 123 | name: Voltage L1 |
||
| 124 | id: voltage_l1 |
||
| 125 | on_value: |
||
| 126 | then: |
||
| 127 | - mqtt.publish_json: |
||
| 128 | topic: !lambda |- |
||
| 129 | return str_sprintf("W/%s/grid/%s/Ac/L1/Voltage", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 130 | payload: |- |
||
| 131 | root["value"] = id(voltage_l1).state; |
||
| 132 | voltage_l2: |
||
| 133 | name: Voltage L2 |
||
| 134 | id: voltage_l2 |
||
| 135 | on_value: |
||
| 136 | then: |
||
| 137 | - mqtt.publish_json: |
||
| 138 | topic: !lambda |- |
||
| 139 | return str_sprintf("W/%s/grid/%s/Ac/L2/Voltage", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 140 | payload: |- |
||
| 141 | root["value"] = id(voltage_l2).state; |
||
| 142 | voltage_l3: |
||
| 143 | name: Voltage L3 |
||
| 144 | id: voltage_l3 |
||
| 145 | on_value: |
||
| 146 | then: |
||
| 147 | - mqtt.publish_json: |
||
| 148 | topic: !lambda |- |
||
| 149 | return str_sprintf("W/%s/grid/%s/Ac/L3/Voltage", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 150 | payload: |- |
||
| 151 | root["value"] = id(voltage_l3).state; |
||
| 152 | current_l1: |
||
| 153 | name: Current L1 |
||
| 154 | id: current_l1 |
||
| 155 | on_value: |
||
| 156 | then: |
||
| 157 | - mqtt.publish_json: |
||
| 158 | topic: !lambda |- |
||
| 159 | return str_sprintf("W/%s/grid/%s/Ac/L1/Current", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 160 | payload: |- |
||
| 161 | root["value"] = id(current_l1).state; |
||
| 162 | current_l2: |
||
| 163 | name: Current L2 |
||
| 164 | id: current_l2 |
||
| 165 | on_value: |
||
| 166 | then: |
||
| 167 | - mqtt.publish_json: |
||
| 168 | topic: !lambda |- |
||
| 169 | return str_sprintf("W/%s/grid/%s/Ac/L2/Current", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 170 | payload: |- |
||
| 171 | root["value"] = id(current_l2).state; |
||
| 172 | current_l3: |
||
| 173 | name: Current L3 |
||
| 174 | id: current_l3 |
||
| 175 | on_value: |
||
| 176 | then: |
||
| 177 | - mqtt.publish_json: |
||
| 178 | topic: !lambda |- |
||
| 179 | return str_sprintf("W/%s/grid/%s/Ac/L3/Current", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 180 | payload: |- |
||
| 181 | root["value"] = id(current_l3).state; |
||
| 182 | power_delivered_l1: |
||
| 183 | name: Power Delivered L1 |
||
| 184 | id: power_delivered_l1 |
||
| 185 | power_delivered_l2: |
||
| 186 | name: Power Delivered L2 |
||
| 187 | id: power_delivered_l2 |
||
| 188 | power_delivered_l3: |
||
| 189 | name: Power Delivered L3 |
||
| 190 | id: power_delivered_l3 |
||
| 191 | power_returned_l1: |
||
| 192 | name: Power Returned L1 |
||
| 193 | id: power_returned_l1 |
||
| 194 | power_returned_l2: |
||
| 195 | name: Power Returned L2 |
||
| 196 | id: power_returned_l2 |
||
| 197 | power_returned_l3: |
||
| 198 | name: Power Returned L3 |
||
| 199 | id: power_returned_l3 |
||
| 200 | gas_delivered: |
||
| 201 | name: Gas Delivered |
||
| 202 | - platform: template |
||
| 203 | name: "Total power" |
||
| 204 | id: total_power |
||
| 205 | lambda: |- |
||
| 206 | return (id(power_consumed).state - id(power_returned).state)*1000.0; |
||
| 207 | update_interval: 1s |
||
| 208 | device_class: power |
||
| 209 | state_class: measurement |
||
| 210 | unit_of_measurement: W |
||
| 211 | on_value: |
||
| 212 | then: |
||
| 213 | - mqtt.publish_json: |
||
| 214 | topic: !lambda |- |
||
| 215 | return str_sprintf("W/%s/grid/%s/Ac/Power", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 216 | payload: |- |
||
| 217 | root["value"] = id(total_power).state; |
||
| 218 | - platform: template |
||
| 219 | name: "Power L1" |
||
| 220 | id: power_l1 |
||
| 221 | lambda: |- |
||
| 222 | return (id(power_delivered_l1).state - id(power_returned_l1).state)*1000.0; |
||
| 223 | update_interval: 1s |
||
| 224 | device_class: power |
||
| 225 | state_class: measurement |
||
| 226 | unit_of_measurement: W |
||
| 227 | on_value: |
||
| 228 | then: |
||
| 229 | - mqtt.publish_json: |
||
| 230 | topic: !lambda |- |
||
| 231 | return str_sprintf("W/%s/grid/%s/Ac/L1/Power", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 232 | payload: |- |
||
| 233 | root["value"] = id(power_l1).state; |
||
| 234 | - platform: template |
||
| 235 | name: "Power L2" |
||
| 236 | id: power_l2 |
||
| 237 | lambda: |- |
||
| 238 | return (id(power_delivered_l2).state - id(power_returned_l2).state)*1000.0; |
||
| 239 | update_interval: 1s |
||
| 240 | device_class: power |
||
| 241 | state_class: measurement |
||
| 242 | unit_of_measurement: W |
||
| 243 | on_value: |
||
| 244 | then: |
||
| 245 | - mqtt.publish_json: |
||
| 246 | topic: !lambda |- |
||
| 247 | return str_sprintf("W/%s/grid/%s/Ac/L2/Power", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 248 | payload: |- |
||
| 249 | root["value"] = id(power_l2).state; |
||
| 250 | - platform: template |
||
| 251 | name: "Power L3" |
||
| 252 | id: power_l3 |
||
| 253 | lambda: |- |
||
| 254 | return (id(power_delivered_l3).state - id(power_returned_l3).state)*1000.0; |
||
| 255 | update_interval: 1s |
||
| 256 | device_class: power |
||
| 257 | state_class: measurement |
||
| 258 | unit_of_measurement: W |
||
| 259 | on_value: |
||
| 260 | then: |
||
| 261 | - mqtt.publish_json: |
||
| 262 | topic: !lambda |- |
||
| 263 | return str_sprintf("W/%s/grid/%s/Ac/L3/Power", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 264 | payload: |- |
||
| 265 | root["value"] = id(power_l3).state; |
||
| 266 | - platform: template |
||
| 267 | name: "Total consumed" |
||
| 268 | id: total_consumed |
||
| 269 | lambda: |- |
||
| 270 | return id(energy_delivered_t1).state + id(energy_delivered_t2).state; |
||
| 271 | update_interval: 1s |
||
| 272 | device_class: energy |
||
| 273 | state_class: total_increasing |
||
| 274 | unit_of_measurement: kWh |
||
| 275 | on_value: |
||
| 276 | then: |
||
| 277 | - mqtt.publish_json: |
||
| 278 | topic: !lambda |- |
||
| 279 | return str_sprintf("W/%s/grid/%s/Ac/Energy/Forward", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 280 | payload: |- |
||
| 281 | root["value"] = id(total_consumed).state; |
||
| 282 | - platform: template |
||
| 283 | name: "Total injected" |
||
| 284 | id: total_injected |
||
| 285 | lambda: |- |
||
| 286 | return id(energy_returned_t1).state + id(energy_returned_t2).state; |
||
| 287 | update_interval: 1s |
||
| 288 | device_class: energy |
||
| 289 | state_class: total_increasing |
||
| 290 | unit_of_measurement: kWh |
||
| 291 | on_value: |
||
| 292 | then: |
||
| 293 | - mqtt.publish_json: |
||
| 294 | topic: !lambda |- |
||
| 295 | return str_sprintf("W/%s/grid/%s/Ac/Energy/Reverse", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 296 | payload: |- |
||
| 297 | root["value"] = id(total_injected).state; |
||
| 298 | |||
| 299 | text_sensor: |
||
| 300 | - platform: dsmr |
||
| 301 | identification: |
||
| 302 | name: Identification |
||
| 303 | id: meter_id |
||
| 304 | on_value: |
||
| 305 | then: |
||
| 306 | - mqtt.publish_json: |
||
| 307 | topic: !lambda |- |
||
| 308 | return str_sprintf("W/%s/grid/%s/Serial", id(portal_id).c_str(), id(device_instance).c_str()); |
||
| 309 | payload: |- |
||
| 310 | root["value"] = id(meter_id).state; |
||
| 311 | p1_version: |
||
| 312 | name: Version |
||
| 313 | |||
| 314 | </pre> |