# Lohberger Pellet Stove > [!CAUTION] > **DISCLAIMER — USE AT YOUR OWN RISK** > > This is an unofficial, private hobby project. It is **not affiliated with, endorsed by or supported by Lohberger**. > "Lohberger" is used only to describe which stove this integration talks to. > > This software controls a **heating appliance that burns fuel**. It can switch the stove on and off and change its > settings, and it relies on a protocol that was worked out by observation, not from official documentation. > Wrong values, bugs or unexpected behaviour can cause damage to the stove, the heating system or the building, > injury, fire, voiding of your warranty, or other loss. > > **The author accepts no responsibility or liability whatsoever for anything that happens through the use, misuse > or inability to use this code**, including any direct, indirect, incidental or consequential damage. The software > is provided "AS IS", without warranties or conditions of any kind; see sections 7 and 8 of the > [Apache License 2.0](LICENSE). Never leave a stove unattended because of this integration, follow the > manufacturer's instructions and local safety rules, and do not use it if you do not accept these terms. > [!NOTE] > **Tested on one stove** with firmware `SW2.0.99` (hardware `HW4.0.0`): switching on and off, the power setting, > reading the heating schedule, and changing its times and weekdays. Everything else is untested. A Home Assistant integration for Lohberger pellet stoves. Home Assistant mimics the vendor server. The stove connects on its own schedule. During each connection the integration reads every configured datapoint (`GETPARAM`) and sends any queued writes (`SETPARAM=`). The used params are reverse engineered! Every param with only a number is still unknown! This integration is only tested with stove firmware `SW2.0.99` (hardware `HW4.0.0`). On any other firmware Home Assistant shows a repair warning and blocks every write; reading values keeps working. ## Features - **Runs inside Home Assistant.** Entities are created directly from the stove's values; no extra server needed. - **Datapoints are edited in the UI** (Settings → Devices & services → Lohberger Pellet Stove → Configure): add, edit, remove, or reset them to the built-in defaults. - **Read and write.** Sensor and binary sensor read values. Switch, number, select and button also write to the stove. - **Scaling without templates.** Each datapoint has a divisor and a number of decimals. For example, temperatures are reported in quarter degrees, so their divisor is 4. - **Heating schedule:** read the six slots, show them as a table and change them from Home Assistant. - **Diagnostics:** last contact, firmware version, communication errors and pending writes. ## Installation 1. Copy `custom_components/lohberger_stove` into your Home Assistant `config/custom_components/` folder (or add this repository to HACS as a custom repository). 2. Restart Home Assistant. 3. Add the integration **Lohberger Pellet Stove**. Keep the listen address `0.0.0.0` and the port `50505` unless you need something else. 4. Point the stove at the Home Assistant host: the stove looks up `netport.lohberger.com` and connects to port `50505`. Override that name on the DNS server the stove gets from your router, then disconnect the stove from mains for a moment. It only looks the name up when it starts, and a normal restart is not enough: without a complete power cut it keeps talking to the vendor server. Until the stove connects for the first time, every datapoint entity shows as unavailable. ## Datapoints Each datapoint becomes one entity: | Field | Meaning | | ------------------ | ---------------------------------------------------------------------- | | Key | Fixed ID (e.g. `p4101_TempKessel`). The entity is tied to it. | | Name | Entity name | | Parameter number | `n` in `GETPARAM` / `SETPARAM=…` | | Type | sensor, binary_sensor, switch, number, select, button | | Divisor / decimals | Shown value = raw ÷ divisor, rounded. Written value = value × divisor. | | On / off value | binary_sensor and switch, e.g. `7000` / `6000` | | Min / max / step | number | | Options | select, one `raw=Label` per line | | Value to send | button | Several datapoints can share one parameter (for example `p4113` as _RostCmdAuf_ and _RostCmdZu_, with different on values). The stove is still asked for that parameter only once per session. Changes in the options dialog collect until you choose **Save and close**. The integration then reloads. Entities of removed datapoints are deleted. ### Writing The stove only accepts commands while it is connected. Switching, setting a number, choosing an option or pressing a button therefore **queues** the write. The entity shows the requested state right away, with the attribute `pending_write: true`. The write goes out at the start of the next session. If the stove does not acknowledge it, it stays queued and is retried at the session after that. ### What can be written For safety, only two parameters, and the heating schedule, can ever be written to the stove: | Parameter | Meaning | Allowed raw values | | --------- | ------------- | ------------------ | | 4096 | On / off | 0, 1 | | 51 | Power setting | 5–10 | Every other parameter is read-only, so none of the stove's setup parameters can be changed from Home Assistant. The list is fixed in the code and cannot be changed in the options: a switch, number, select or button datapoint is only accepted for these two parameters and only with values in their range, and every write is checked again before it is queued. A power-setting number configured with a wider range keeps working and only offers 5–10. The heating schedule is written with its own command; see [Changing the schedule](#changing-the-schedule). ## Heating schedule The stove keeps a heating schedule of six time slots. They are read once a minute instead of in every session (it only changes through the stove's panel or app). Each slot is a sub-device of the stove, **Schedule slot 1** to **Schedule slot 6**, listed on the stove's device page. A slot's page holds its sensor and its controls, in order: **1 Start time**, **2 End time**, then **3 Monday** to **9 Sunday**. The numbers keep that order, because Home Assistant sorts a device's entities by name. The slot's sensor carries the name of the slot: - The state is the time range, e.g. `07:23–09:30`, or `off` for an unused slot. - The attributes hold `start`, `end`, `weekdays`, `days`, `days_mask` and `mode`. - `weekdays` lists the days the slot applies to, `mon` to `sun`. `days` shows the same as bits, bit 0 for Monday: `1101111` means every day but Wednesday. The meaning of `mode` (seen: `3` and `255`) is unknown. ### Week view The integration brings its own card, which draws the week as one row per day, 0 to 24 hours across, with every heating period as a green bar. Today is highlighted and a red line marks the current time; a striped bar is a change still waiting for the stove. Select a bar to open its schedule slot. Open a dashboard, choose **Edit dashboard** → **Add card**, and search for **Lohberger heating schedule**. Or add a **Manual** card: ```yaml type: custom:lohberger-schedule-card title: Heating schedule # optional ``` The card finds the schedule slots itself. After an update, reload the browser page if the card still looks old. ### Table The integration cannot put a card on your dashboard by itself. To see the schedule as one table, open a dashboard, choose **Edit dashboard** → **Add card** → **Manual**, and paste: ```yaml type: markdown title: Heating schedule content: | | Slot | Time | Days | | :-: | :-: | :-- | {%- for e in integration_entities("lohberger_stove") | select("search", "schedule_slot_\d$") | sort %} | {{ loop.index }} | {{ states(e) }} | {{ (state_attr(e, "weekdays") or []) | map("title") | join(", ") }} | {%- endfor %} ``` The card finds the slots through the integration, so it works whatever the entities are called. To change the schedule from the dashboard, add a **Manual** card per slot as well. It shows the start and end, and one button per weekday that turns the day on or off with a tap; tap a time to change it. For slots 2 to 6, change every `slot_1` and the title. The entity IDs assume the device is called _Lohberger Pellet Stove_; copy yours from the slot's device page if you renamed it, or if you installed a version before 0.1.3, whose entities keep their old IDs. The slot's device page also offers **Add to dashboard**, which builds a card from its entities. ```yaml type: glance title: Slot 1 columns: 9 state_color: true entities: - entity: time.lohberger_pellet_stove_schedule_slot_1_1_start_time name: Start - entity: time.lohberger_pellet_stove_schedule_slot_1_2_end_time name: End - entity: switch.lohberger_pellet_stove_schedule_slot_1_3_monday name: Mo show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_4_tuesday name: Tu show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_5_wednesday name: We show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_6_thursday name: Th show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_7_friday name: Fr show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_8_saturday name: Sa show_state: false tap_action: action: toggle - entity: switch.lohberger_pellet_stove_schedule_slot_1_9_sunday name: Su show_state: false tap_action: action: toggle ``` Put the six cards in a **Vertical stack** card to keep them together. ### Changing the schedule - **Start and end:** every slot has the time entities **1 Start time** and **2 End time** on its device page. Set them on a dashboard like any other time. A slot that never had times shows none; set it up with the action below. - **Weekdays:** every slot has one switch per weekday, **3 Monday** to **9 Sunday**. Turn a day on or off to add it to the slot or remove it. - **Weekdays, unused slots, automations:** the action **Set schedule slot** (`lohberger_stove.set_schedule_slot`) changes start, end and weekdays together. Fields you leave out keep their current value. - **Turning a slot off:** switch off every weekday, or deselect them all in the action (`weekdays: []`), the way the stove's own app does it. The times stay as they were, also across restarts, even if the stove itself forgets them: select a weekday again and the slot is back with its times. **Clear slot** turns the slot off and drops the times as well. ```yaml action: lohberger_stove.set_schedule_slot data: device_id: slot: 5 start: "06:00" end: "08:00" weekdays: [sat, sun] ``` Like every write, a change is queued and sent the next time the stove connects; until then the slot shows the new value with `pending_write: true`. That session reads the schedule back, so the sensors show what the stove stored. Only the changed slot is written, and the unknown `mode` field is sent back as it was read. A slot needs a start, an end later than the start, and at least one weekday, unless it is being turned off; anything else is refused before it is queued. ## Connection handling - The stove answers each command with one bare value and no terminator. A reply is everything that arrives until the line has been quiet for 50 ms, so a reply split across two packets is still one value. Spaces and `;` around a value are dropped. - A reply that comes in after its timeout is discarded, so it never lands on the next parameter. - Every reply has a timeout and so does the whole session (120 s); a stove that stops answering ends the session. - If the stove hangs up mid-session, the values read so far are kept. - A new connection replaces a stuck one, so sessions never pile up. - Each parameter is asked once per session, even when several datapoints use it. - Write acknowledgements are checked; a failed write stays queued for the next session. - Everything runs in Home Assistant's event loop, and the port is released cleanly when the integration unloads. The protocol details come from a recording of the stove talking to the vendor server (firmware `SW2.0.96`): the stove acknowledges a write with `OK` and answers `BYE` with `BYE`. A `SETPARAM` reply counts as rejected when it contains `ERR`, `FAIL`, `NAK` or `NOK`. With debug logging enabled, every command and reply is logged: ```yaml logger: logs: custom_components.lohberger_stove: debug ``` The reply timeout, the delay between commands and the availability timeout can be changed under **Configure → Connection settings**. ## Development The repository is based on [jpawlowski/hacs.integration_blueprint](https://github.com/jpawlowski/hacs.integration_blueprint). See [`AGENTS.md`](AGENTS.md) and [`docs/development/`](docs/development) for the tooling (`script/setup/bootstrap`, `script/lint`, `script/type-check`, `script/test`, `script/develop`). `script/fake_stove.py` stands in for the stove: it connects to a running instance, answers every command and prints the conversation: ```bash script/fake_stove.py --port 50505 # one session script/fake_stove.py --port 50505 --every 30 # reconnect every 30 s, like the real stove ``` ## License Licensed under the [Apache License, Version 2.0](LICENSE). See also [NOTICE](NOTICE). Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the license for the specific language governing permissions and limitations.