Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 additional thermostat attributes #122

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

msp-joe
Copy link

@msp-joe msp-joe commented Sep 6, 2024

Thanks for your maintenance of the package.

A couple additional attributes that seem reasonable and have been useful in my fork. Attribute naming might need to align with how you like.

  • displayLockPIN outputs the actual pin or zero if it's unlocked. The pin would also probably be pretty low harm to expose to HASS but I just do a unlocked check for my purposes in the integration logic rather than in the app.

  • ctIFCOperatingHeatCoolMode puts out things like Idle, Fan Cool, Fan, Fan Heat, *Aux Heat from my memory.

  • ctOutdoorMode is mostly idle and cooling in the summer but has a lot of values in the wintertime I cannot 100% remember like defrost, heating startup.

  • Finally alertMediaAirFilterDays just gives the count up for how long the filter has been installed since the counter was reset. There's a humidifier pad version but I have no humidifier to try this with or know whether that would be valuable.

         "furnace_mode": self.thermostat["ctIFCOperatingHeatCoolMode"],
         "heatpump_mode": self.thermostat["ctOutdoorMode"],
         "thermostat_locked": int(self.thermostat["displayLockPIN"] != 0),
         "filter_days": self.thermostat["alertMediaAirFilterDays"]
    

@apetrycki
Copy link
Owner

My system doesn't have ctIFCOperatingHeatCoolMode, it looks to report a null string or something. It doesn't look like it hurts anything, though.

The lock probably should be converted to a boolean.

ctOutdoorMode has some trailing spaces that would be good to remove.

You also may want to consider making the filter and lock sensors instead of attributes. People will probably want to use those for automations.

* renaming furnace mode to indoor mode and handling AH vs Furnace divide
* renaming heatpump mode to outdoor mode
* switching locked as an int to unlocked as a boolean which matches the binary sensor type for locks
*renaming filter age to include the word media to differentiate between this and electronic filters
@msp-joe
Copy link
Author

msp-joe commented Sep 17, 2024

My PR is updated with a few of the updates you suggested.

The modes are now being stripped for trailing whitespace and the indoor mode (renamed from furnace mode) should work for folks with air handlers vs furnace but I cannot test myself. I renamed heatpump mode to outdoor mode just to fit in.

Moving the lock to a separate sensor is going to be a bit of lift because there are no binary sensors defined in this integration. I did switch it to boolean and flipped the output and naming to match the lock device class.

I did setup the filter days as a separate sensor to see how it would appear. This required setting up a new sensor type in sensor.py. The duration device class appear to be a bit odd in the way it displays and always converts units (at least on my system) to HH:MM:SS which yields very silly looking output. I guess your call. Happy to update my commit either way.

sensor.py line 123

    "duration": {
        "device_class": SensorDeviceClass.DURATION,
        "native_unit_of_measurement": UnitOfTime.DAYS   ,
        "state_class": SensorStateClass.MEASUREMENT,
        "icon": "mdi:calendar-clock",
    },
}

async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Add a Daikin Skyport Sensor entity from a config_entry."""

    data = hass.data[DOMAIN][entry.entry_id]
    coordinator: DaikinSkyportData = data[COORDINATOR]

    for index in range(len(coordinator.daikinskyport.thermostats)):
        sensors = coordinator.daikinskyport.get_sensors(index)
        for sensor in sensors:
            if sensor["type"] not in ("temperature", "humidity", "score",
                                      "ozone", "particle", "VOC", "demand",
                                      "power", "frequency_percent","actual_status",
                                      "airflow","duration") or sensor["value"] == 127.5 or sensor["value"] == 65535:
                continue
            async_add_entities([DaikinSkyportSensor(coordinator, sensor["name"], sensor["type"], index)], True)

daikinskyport.py line 276

        if self.thermostats[index]['NumMediafilters']:
            sensors.append({"name": f"{name} Indoor media filter ", "value": thermostat['alertMediaAirFilterDays'], "type": "duration"})


        return sensors

There's currently a popup warning appearing if you trigger the aux switch due to using async_write_ha_state.  

https://developers.home-assistant.io/docs/asyncio_thread_safety/#async_write_ha_state

This change schedules the updates so they can be applied in a thread safe way.
@msp-joe
Copy link
Author

msp-joe commented Oct 10, 2024

Made a change to switch.py to move to self.schedule_update_ha_state() from self. async_write_ha_state(). This is recommended and the use of async_write_ha_state is throwing a warning popup when triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants