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

Set running time #47

Open
Rumsgurke opened this issue Feb 4, 2024 · 0 comments
Open

Set running time #47

Rumsgurke opened this issue Feb 4, 2024 · 0 comments

Comments

@Rumsgurke
Copy link

First of all, thank you very much. The integration works like a charm. With some actors like Rademacher DuoFern 9471-1 you can't set the maximum and minimum positions manually. That value must be set via the interface as running time in seconds. Such an actor isn't working properly without that value. Therefore I've copied one of your services locally and made some adjustments:

def set_running_time(call: ServiceCall) -> None:
    device_id = None
    hass_device_id = call.data.get('device_id', None)
    time = call.data.get('time', None)

    def get_device_id(hass_entity_id):
        for ent in hass.data[DOMAIN]['devices'].values():
            if ent.entity_id == hass_entity_id:
                return ent._duofernId
        return None

    device_ids = [get_device_id(i) for i in hass_device_id]
    _LOGGER.info(f"Updating these devices {' '.join(device_ids)}")
    if not device_ids:
        _LOGGER.warning("Found no valid device ids???")
    for device_id in device_ids:
        if device_id is not None:
            if device_id not in hass.data[DOMAIN]['stick'].duofern_parser.modules['by_code']:
                _LOGGER.warning(
                    f"{device_id} is not a valid duofern device, I only know {hass.data[DOMAIN]['stick'].duofern_parser.modules['by_code'].keys()}. Gonna handle the other devices in {device_ids} though.")
                continue
            _LOGGER.info(f"update runningTime on {device_id} with time {time}")
            getDuofernStick(hass).command(device_id,"runningTime",time)

The result can be controlled by the services dump_device_state. I liked the idea to do it as a service. You may want to add a service like that to a future release.

Best regards.

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

No branches or pull requests

1 participant