Skip to content

Add new sensor for fyta - #180328

Draft
dontinelli wants to merge 5 commits into
home-assistant:devfrom
dontinelli:dontinelli-fyta-new-sensor
Draft

Add new sensor for fyta#180328
dontinelli wants to merge 5 commits into
home-assistant:devfrom
dontinelli:dontinelli-fyta-new-sensor

Conversation

@dontinelli

@dontinelli dontinelli commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Proposed change

Add a new sensor to track when the FYTA-sensor has last been updated.
Cf. https://github.com/orgs/home-assistant/discussions/3270

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a diagnostic FYTA sensor intended to expose the plant sensor’s last update time.

Changes:

  • Adds the FYTA sensor entity description and translation.
  • Updates generated MDI frontend metadata.
  • Extends diagnostic sensor coverage conceptually, but snapshots are missing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
homeassistant/components/fyta/sensor.py Defines the new diagnostic sensor.
homeassistant/components/fyta/strings.json Adds its display name.
pylint/plugins/pylint_home_assistant/generated/mdi_icons.py Changes generated frontend version metadata.
Suppressed comments (2)

homeassistant/components/fyta/sensor.py:138

  • Use the timestamp contract for this date-and-time value. The FYTA fixture provides last_updated as 2023-01-10 10:10:00; declaring it as DATE mislabels a datetime and can make consumers parse or display it incorrectly. Use TIMESTAMP and normalize it to a timezone-aware datetime if the library returns a naive value.
        device_class=SensorDeviceClass.DATE,

homeassistant/components/fyta/sensor.py:140

  • Update the sensor snapshot to cover the new entity. test_all_entities currently has no entry/state snapshot for this sensor, so the key mismatch and the datetime device-class contract are not exercised.
        value_fn=lambda plant: plant.last_updated,

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread homeassistant/components/fyta/sensor.py Outdated
Comment thread homeassistant/components/fyta/strings.json
Copilot AI review requested due to automatic review settings August 26, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

homeassistant/components/fyta/sensor.py:138

  • Expose this value as a timezone-aware timestamp instead of a date. plant.last_updated contains a time component (for example, the FYTA fixture supplies 2023-01-10 10:10:00), so DATE misclassifies the value and can discard or misrender the update time; use TIMESTAMP and ensure the library value has the correct timezone.
        device_class=SensorDeviceClass.DATE,

homeassistant/components/fyta/sensor.py:140

  • Document the new sensor in the FYTA documentation and link that documentation PR here. The published FYTA “Supported functionality” sensor table enumerates each sensor but does not include last_sensor_update, while this PR leaves the documentation link and checklist item empty.
    FytaSensorEntityDescription(
        key="last_sensor_update",
        translation_key="last_sensor_update",
        device_class=SensorDeviceClass.DATE,
        entity_category=EntityCategory.DIAGNOSTIC,
        value_fn=lambda plant: plant.last_updated,

Comment thread homeassistant/components/fyta/sensor.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 26, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

homeassistant/components/fyta/sensor.py:135

  • Add and regenerate the sensor snapshots for this new entity. test_all_entities snapshots every registry entry and state, but test_sensor.ambr has no last_sensor_update entries, so the existing snapshot test fails when this entity is added.
    FytaSensorEntityDescription(

Comment thread homeassistant/components/fyta/sensor.py Outdated
Copilot AI review requested due to automatic review settings August 26, 2026 18:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

homeassistant/components/fyta/sensor.py:138

  • Use the timestamp device class and make the test fixtures timezone-aware. last_updated is a full datetime (the snapshots include a time, and the connector returns it with the configured timezone), while DATE represents a calendar date; this prevents Home Assistant and its frontend from handling the value as a timestamp.
        device_class=SensorDeviceClass.DATE,

Copilot AI review requested due to automatic review settings August 26, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@dontinelli
dontinelli marked this pull request as ready for review August 26, 2026 19:16
),
FytaSensorEntityDescription(
key="last_updated",
translation_key="last_sensor_update",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sensor feels like it's more terminology of Home Assistant. What would it be in the context of Fyta? Last device update? Last plant update? I think it's better to name it to something related to Fyta that users can relate to. :)

@home-assistant
home-assistant Bot marked this pull request as draft August 26, 2026 20:59
@home-assistant

Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants