-
Notifications
You must be signed in to change notification settings - Fork 12
MQTT Home Assistant
lxp-bridge includes support for publishing HomeAssistant-compatible auto-discovery messages on startup.
The configuration is done as subsection of mqtt
like this:
mqtt:
[..]
homeassistant:
enabled: true
prefix: homeassistant
The prefix
shown here defaults to homeassistant
, and is used as the first component of the discovery topics. This should normally be left as default as this is where a default HA installation expects them.
Assuming a datalogger serial number of 3333333333
, these messages are published to topics such as homeassistant/sensor/3333333333_soc/config
and look a bit like this:
{
"device_class":"battery",
"name":"Battery Percentage",
"state_topic":"lxp/3333333333/inputs/all",
"state_class":"measurement",
"value_template":"{{ value_json.soc }}",
"unit_of_measurement":"%",
"unique_id":"lxp_3333333333_soc"
}
This tells HomeAssistant that it can watch the topic lxp/3333333333/inputs/all
, look into it for a key called soc
, and record that as a percentage with the label "Battery Percentage".
The state_topic
honours the namespace
setting from configuration; if you change it then new discovery messages will need to be sent for HA to continue seeing data.
From v0.10, an improvement to the structure of these messages has been made.
They are now published to a new topic, such as homeassistant/sensor/lxp_3333333333/soc/config
And have the following content:
{
"device_class":"battery",
"name":"Battery Percentage",
"state_topic":"lxp/3333333333/inputs/all",
"state_class":"measurement",
"value_template":"{{ value_json.soc }}",
"unit_of_measurement":"%",
"unique_id":"lxp_3333333333_soc",
"device":{"manufacturer":"LuxPower","name":"lxp_3333333333","identifiers":["lxp_3333333333"]},
"availability":{"topic":"lxp/LWT"}
}
More controls have also been added.
If you're relying on Home Assistant, consider configuring lxp-bridge
to publish the value of all holding registers on startup. This means HA can show the correct value at all times, rather than sometimes showing Unknown
until a control is first used.
Modify the inverter
section of the config, like so:
inverters:
- enabled: true
[..]
publish_holdings_on_connect: true
TODO; see the source code for now
The controls are grouped by three broad areas of functionality - charging batteries from the grid; "charge priority"; and discharging the batteries back to the grid.
As a general pattern, you need to specify a timeslot (the default value, 00:00-00:00
, means "never") before the on/off switches will do anything. For full manual control, or if you want to rely on Home Assistant automation, specify 00:00-23:59
as the timeslot and then toggle the on/off switches as desired.
If you want to rely on the inverter scheduling charge and discharge periods itself, have the switches always enabled and specify the timeslots. If you've blocked access from the cloud platform, you should turn on the timesync scheduler, as the inverters' internal clocks tend to drift and they don't automatically account for DST.
- AC Charge (switch)
- System Charge Rate (percentage)
- System Discharge Rate (percentage)
- AC Charge Limit (percentage)
- Charge From AC Lower Limit (percentage)
- Charge From AC Upper Limit (percentage)
- AC Charge Timeslot (1, 2, 3) (time period)
- Charge Priority (switch)
- Forced Charge Limit (percentage)
- Charge Priority Timeslot (1, 2, 3) (time period)
- Forced Discharge (switch)
- Forced Discharge Limit (percentage)
- Discharge Cutoff (percentage)
- Discharge Cutoff for EPS (percentage)
- Forced Discharge Timeslot (1, 2, 3) (time period)