Commit Graph
17 Commits
Author SHA1 Message Date
GermanBluefox 1883937e4a Bump version 2026-05-16 20:07:53 +02:00
7dd63fa9c8 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-16 19:49:12 +02:00
BluefoxandGitHub 5f57a27ff6 Merge branch 'master' into upstream-pr-entity-filter 2026-05-16 19:20:43 +02:00
GermanBluefox 34ac9d9220 Fixed linter 2026-05-16 19:11:49 +02:00
BluefoxandGitHub 12e59a82ef Merge pull request #174 from biglouis/fix/dynamic-attribute-objects-on-state-changed
fix: dynamically create missing attribute objects in state_changed handler
2026-05-16 19:06:47 +02:00
mokusone 0512ee7cd3 fix(filter): cleanup must work for flat-state entities (no parent channel)
The previous cleanup implementation only iterated objects with
type === 'channel' and read entity_id from native. Both assumptions
break for entities written by older adapter versions: those exist as
flat states under hass.0.entities.<domain>.<entity_id>.<sub> with no
parent channel object and often no native.entity_id.

The admin UI shows them as folders because sub-states are present, but
`iobroker object get hass.0.entities.text.iob_…` returns "not found".
So the cleanup found nothing to delete even with valid patterns.

Refactor: iterate every object under entities.*, derive entity_id from
the first two path components after the namespace prefix, group by
entity_id, then delete each id individually (longest first, no
recursive flag — there is no parent to recurse into). Custom-config
protection still applies per entity group.

Works for both old flat-state and new channel+sub-state structures.
2026-05-15 04:14:48 +02:00
mokusone a40dc58e35 feat(filter): add cleanupExcludedOnStart option to delete stale objects
When enabled, on each adapter start the adapter scans all existing
hass.0.entities.* channels and deletes those whose entity_id matches
any of the configured excludePatterns. This complements the existing
filter (which only prevents new objects from being created) by also
cleaning up objects that were synced before the filter was activated
or before the patterns were extended.

Safety:
- Channels (and any of their sub-states) holding common.custom config
  (history/influxdb/sql) are kept and a warning is logged so the user
  can decide manually.
- Existing deleteStaleObjects() 50% sanity-guard is intentionally NOT
  applied here — the user explicitly opted in to the cleanup.
- Per-id deletion only logs when verboseFilterLog is also active.

Default is false (opt-in). Adds new admin checkbox + i18n keys for all
11 languages (machine translations for non-en/de still pending).
2026-05-15 04:14:41 +02:00
mokusone fc7efd4768 feat(filter): add verbose filter logging option
New `verboseFilterLog` boolean (default `false`). When enabled, the initial
sync logs every excluded entity_id individually on INFO level. This is
useful when iterating on exclude patterns or verifying that the filter
catches the intended entities.

The verbose output is intentionally limited to the first sync. Subsequent
debouncedSync() calls only emit the aggregate count to avoid log spam
during normal operation. Live `state_changed` events for filtered entities
remain on DEBUG.

Admin UI gets a checkbox below the patterns field; i18n keys added for
all 11 supported languages.
2026-05-14 11:40:28 +02:00
mokusone 6889664c28 feat(filter): integrate exclude filter into parseStates and state_changed
Adapter now consults the exclude-pattern list (new `native.excludePatterns`
config option, multi-line string) at two points:

- `parseStates()` skips matching entities entirely. They are not registered
  as ioBroker objects and no state is written. A summary INFO line reports
  the count when the filter dropped anything from a sync.
- The `state_changed` event handler short-circuits matching live updates
  with a DEBUG line, so a filtered entity that still emits state changes
  in HA does not cause any churn in ioBroker.

Patterns are parsed once at adapter start: trimmed, empty lines and lines
starting with `#` are dropped. An empty resulting list means the filter is
inactive — adapter behaviour is then identical to the previous version.

Default config ships with example comments only, so existing installations
see no functional change after the update.
2026-05-14 11:40:28 +02:00
mokusone 9b95ece284 feat(filter): add isExcluded helper with unit tests
Glob-based entity_id matcher used by the upcoming exclude-filter feature.
Single wildcard `*` (matches any sequence including dots), all other characters
matched literally with regex metacharacters escaped. Case-sensitive, anchored.

Empty pattern array always returns false, so the helper is a no-op when the
adapter is not configured to filter anything.

New mocha unit-test suite invoked via `npm run test:unit` (separate from the
existing js-controller-backed test:integration).
2026-05-14 11:40:28 +02:00
Torsten Pattberg cb3f490e25 fix: dynamically create missing attribute objects in state_changed handler
When Home Assistant reports a new attribute for an entity after the initial
sync (e.g. source_list or media_channel appearing when a media player becomes
active), setState was called without a corresponding ioBroker object — causing
'has no existing object' warnings.

Fix: check if the attribute object exists in hassObjects before calling
setState. If missing, create it on-the-fly via setForeignObjectAsync before
writing the state.
2026-05-12 15:58:31 +02:00
Matthias KleineandGitHub 47b80f47c2 Merge branch 'master' into master 2026-05-05 12:07:10 +02:00
GermanBluefox a64ef243f0 Tried to keep the custom settings of the objects when updating them with new data from HASS 2026-05-05 10:01:38 +02:00
Matthias Kleine 5657211716 Use ENV var SUPERVISOR_TOKEN as fallback for password 2026-04-28 11:15:02 +02:00
Matthias Kleine 7575b129c0 Use /core/ instead of /api/ when connecting to supervisor directly 2026-04-28 11:05:24 +02:00
GermanBluefox bc74169c7e Merge https://github.com/ioBroker/ioBroker.hass/pull/129 2026-03-31 22:11:09 +02:00
GermanBluefox ebca1ad36c MIgrate adapter to Typescript 2026-03-31 19:44:44 +02:00