Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
33af016
chore: add pytest test infrastructure
wxtry Mar 4, 2026
b9dc4b1
chore: remove pycache from tracking, update gitignore
wxtry Mar 4, 2026
d45fb92
feat: add constants for auto-switch and offline timeout options
wxtry Mar 4, 2026
005c268
feat: update manifest for fork - add recorder dep, bump version
wxtry Mar 4, 2026
5979be3
feat: add translations for auto-switch and offline timeout options
wxtry Mar 4, 2026
f5d0600
feat: expand OptionsFlowHandler with auto-switch and offline timeout
wxtry Mar 4, 2026
4180d45
test(A): add failing tests for auto-switch report mode guard
wxtry Mar 4, 2026
dd0707a
fix: OptionsFlowHandler persist options via async_create_entry(data=...)
wxtry Mar 4, 2026
1efc972
feat(A): make auto-switch report mode configurable, default historic
wxtry Mar 4, 2026
9174509
test(C): add failing tests for configurable offline timeout
wxtry Mar 4, 2026
5c49932
feat(C): make offline timeout configurable per device
wxtry Mar 4, 2026
8de758d
test(B): add failing tests for batch history statistics import
wxtry Mar 4, 2026
99aeaa6
feat(B): import TLV batch history data into HA statistics
wxtry Mar 4, 2026
e56f413
feat(B): handle JSON type 17 batch data with statistics import
wxtry Mar 4, 2026
7de5259
fix(B): lowercase MAC in statistic_id to satisfy HA validation
wxtry Mar 4, 2026
e25541a
fix(B): use async_add_external_statistics for external data import
wxtry Mar 4, 2026
80034fb
fix(B): align statistics timestamps to hour boundary
wxtry Mar 4, 2026
2efb74d
fix(B): support CMD 0x31 history data from firmware 2.x
wxtry Mar 7, 2026
c45d782
chore: restore upstream manifest metadata
wxtry Mar 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
venv/
__pycache__/
53 changes: 40 additions & 13 deletions custom_components/qingping_cgs1/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError

from .const import DOMAIN, MQTT_TOPIC_PREFIX, QP_MODELS, DEFAULT_MODEL
from .const import (
DOMAIN, MQTT_TOPIC_PREFIX, QP_MODELS, DEFAULT_MODEL,
CONF_AUTO_SWITCH_REPORT_MODE, DEFAULT_AUTO_SWITCH_REPORT_MODE,
CONF_OFFLINE_TIMEOUT_MINUTES, DEFAULT_OFFLINE_TIMEOUT_MINUTES,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -202,29 +206,52 @@ async def async_step_init(
) -> FlowResult:
"""Manage the options."""
if user_input is not None:
# Update the config entry
# Update model in entry data
new_data = {
**self.config_entry.data,
CONF_MODEL: user_input[CONF_MODEL]
CONF_MODEL: user_input[CONF_MODEL],
}

self.hass.config_entries.async_update_entry(
self.config_entry,
data=new_data,
self.config_entry, data=new_data,
)

# Reload the integration to apply changes
await self.hass.config_entries.async_reload(self._config_entry_id)

return self.async_create_entry(title="", data=user_input)
await self.hass.config_entries.async_reload(
self.config_entry.entry_id
)

# Return options via async_create_entry (this sets config_entry.options)
return self.async_create_entry(title="", data={
CONF_AUTO_SWITCH_REPORT_MODE: user_input.get(
CONF_AUTO_SWITCH_REPORT_MODE,
DEFAULT_AUTO_SWITCH_REPORT_MODE,
),
CONF_OFFLINE_TIMEOUT_MINUTES: user_input.get(
CONF_OFFLINE_TIMEOUT_MINUTES,
DEFAULT_OFFLINE_TIMEOUT_MINUTES,
),
})

return self.async_show_form(
step_id="init",
data_schema=vol.Schema({
vol.Required(
CONF_MODEL,
default=self.config_entry.data.get(CONF_MODEL, DEFAULT_MODEL)
default=self.config_entry.data.get(CONF_MODEL, DEFAULT_MODEL),
): vol.In(QP_MODELS),
vol.Required(
CONF_AUTO_SWITCH_REPORT_MODE,
default=self.config_entry.options.get(
CONF_AUTO_SWITCH_REPORT_MODE,
DEFAULT_AUTO_SWITCH_REPORT_MODE,
),
): bool,
vol.Required(
CONF_OFFLINE_TIMEOUT_MINUTES,
default=self.config_entry.options.get(
CONF_OFFLINE_TIMEOUT_MINUTES,
DEFAULT_OFFLINE_TIMEOUT_MINUTES,
),
): vol.All(vol.Coerce(int), vol.Range(min=5, max=1440)),
}),
)

)
10 changes: 8 additions & 2 deletions custom_components/qingping_cgs1/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# Default values for offsets and update interval
DEFAULT_OFFSET = 0
DEFAULT_UPDATE_INTERVAL = 15
DEFAULT_UPDATE_INTERVAL = 300 # 5 minutes (was 15 seconds)

# MQTT topics
MQTT_TOPIC_PREFIX = "qingping"
Expand Down Expand Up @@ -97,4 +97,10 @@
CONF_NIGHT_MODE_END_TIME = "night_mode_end_time"
CONF_AUTO_SLIDING_TIME = "auto_slideing_time"
CONF_SCREENSAVER_TYPE = "screensaver_type"
CONF_TIMEZONE = "timezone"
CONF_TIMEZONE = "timezone"

# Fork: Per-device configurable options
CONF_AUTO_SWITCH_REPORT_MODE = "auto_switch_report_mode"
CONF_OFFLINE_TIMEOUT_MINUTES = "offline_timeout_minutes"
DEFAULT_OFFLINE_TIMEOUT_MINUTES = 65
DEFAULT_AUTO_SWITCH_REPORT_MODE = False
2 changes: 1 addition & 1 deletion custom_components/qingping_cgs1/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Qingping",
"codeowners": ["@mash2k3"],
"config_flow": true,
"dependencies": ["mqtt"],
"dependencies": ["mqtt", "recorder"],
"documentation": "https://github.com/mash2k3/qingping_cgs1",
"iot_class": "local_push",
"issue_tracker": "https://github.com/mash2k3/qingping_cgs1/issues",
Expand Down
Loading