Code Monkey home page Code Monkey logo

ha_blnet's Issues

Error during setup of component blnet

Hello Nielstron,
I got a problem with installing the blnet component in Homeassistant.
I used HACS to import a user defined repository. Using GitHub path: https://github.com/nielstron/ha_blnet.git
This adds the files into my custom_components directory. I've added the mentioned lines in configuration.yaml.
After restarting HA I'll get the following error: Invalid config. The following integrations and platforms could not set up: blnet
I attached the log.
HA blnet installation error.txt

I am a beginner with homeassistant, therefore I am not quite sure how to get rid of the error.
Thanks,
Michael

Warning in current version of HA

Moin,

after updating to 2024.3 of HA I got this warning in the logs:

TEMP_CELSIUS was used from blnet, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.CELSIUS instead, please report it to the author of the 'blnet' custom integration

It would be great if this can get solved, since I like the addon I would like to go on using it.

Regards and thanks
Georg

Leading zero in password are omitted if password is all digits

A leading zero in the password of an all digit password is omitted by python when the password is not put in quotes, therefore leading to an incorrect password and a failed login.

Please add a corresponding information in the readme to avoid others stumbling across the same error as me.

Names not read from output

Hi!
I very much enjoy your plugin.
When I run:

blnet = BLNET(ip, password='', timeout=5)
print(blnet.fetch())

I get this output:

{'analog': {1: {'id': '1', 'name': 'T.Kollektor1', 'value': '11.4', 'unit_of_measurement': '°C'},

Is there a way to automatically map these name values to the HA sensor friendly_names?
I currently see "blnet analog 1" and so on.

More than one UVR1611 over blnet

Hello ! I have installed your blnet solution for "Technische Alternative" to read out digital and Analog Values from a UVR 1611. This works perfect with one UVR when i use the canNode from the UVR1611. It did not work with the CanNode from the BLNet.
But in this configuration we have 2 UVR166, where i want to read out the values.
The Value of the CanNode is a integer requierd, so it is not possible to set the 2 CanNode adresses.
It also not works with 2 packages with 2 different settings for the CanNodes.
So do you a solution for that ?

Incorrect interpretation of "value"

Hi,

in "switch.py" you assume "1", "2" or "3" as content of attribute "value", but it contains "EIN" or "AUS".
Changed this for me and now I'm able to show icons relating the state.

regards
Georg

"""
Connect to a BL-NET via it's web interface and read and write data

Switch to control digital outputs
"""
import logging

from homeassistant.const import (
    STATE_UNKNOWN)
from homeassistant.components.switch import SwitchDevice

_LOGGER = logging.getLogger(__name__)

DOMAIN = 'blnet'

MODE = 'mode'
FULLMODE = 'fullmode'
FRIENDLY_NAME = 'friendly_name'


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the BLNET component"""

    if discovery_info is None:
        _LOGGER.error("No BL-Net communication configured")
        return False

    switch_id = discovery_info['id']
    blnet_id = discovery_info['name']
    comm = hass.data['DATA_{}'.format(DOMAIN)]

    add_devices([BLNETSwitch(switch_id, blnet_id, comm),
                 BLNETModeSwitch(switch_id, blnet_id, comm)], True)
    return True


class BLNETSwitch(SwitchDevice):
    """
    Representation of a switch that toggles a digital output of the UVR1611.
    """

    def __init__(self, switch_id, blnet_id, comm):
        """Initialize the switch."""
        self._blnet_id = blnet_id
        self._id = switch_id
        self.communication = comm
        self._name = blnet_id
        self._friendly_name = blnet_id
        self._state = STATE_UNKNOWN
        self._assumed_state = True
        self._icon = None
        self._mode = STATE_UNKNOWN
        self._fullmode = STATE_UNKNOWN
        self._last_updated = None
        self._is_standby = None

    def update(self):
        """Get the latest data from communication device """
        # check if new data has arrived
        last_blnet_update = self.communication.last_updated()

        if last_blnet_update == self._last_updated:
            return

        sensor_data = self.communication.data.get(self._blnet_id)

        if sensor_data is None:
            return

        self._friendly_name = sensor_data.get('friendly_name')
        if sensor_data.get('value') == 'EIN':
            self._state = 'on'
            if sensor_data.get('mode') == 'AUTO':
                self._icon = 'mdi:cog-outline'
            else:
                self._icon = 'mdi:cog'
        # Nonautomated switch, toggled off => switch off
        else:
            self._state = 'off'
            if sensor_data.get('mode') == 'AUTO':
                self._icon = 'mdi:cog-off-outline'
            else:
                self._icon = 'mdi:cog-off'

        self._mode = sensor_data.get('mode')
        self._fullmode = sensor_data.get('mode') + '/' + sensor_data.get('value')
        self._last_updated = last_blnet_update
        self._assumed_state = False

    @property
    def name(self):
        """Return the name of the switch."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def icon(self):
        """Return the state of the device."""
        return self._icon

    @property
    def device_state_attributes(self):
        """Return the state attributes of the device."""
        attrs = {}

        attrs[MODE] = self._mode
        attrs[FULLMODE] = self._fullmode
        attrs[FRIENDLY_NAME] = self._friendly_name
        return attrs

    @property
    def is_on(self):
        """Return true if device is on."""
        return self._state

    def turn_on(self, **kwargs):
        """Turn the device on."""
        if self._mode != 'AUTO':
            self.communication.turn_on(self._id)
            self._state = 'on'
            self._assumed_state = True

    def turn_off(self, **kwargs):
        """Turn the device off."""
        if self._mode != 'AUTO':
            self.communication.turn_off(self._id)
            self._state = 'off'
            self._assumed_state = True

    @property
    def assumed_state(self)->bool:
        return self._assumed_state

class BLNETModeSwitch(SwitchDevice):
    """
    Representation of a switch that toggles the operation mode
    of a digital output of the UVR1611. On means automated
    """

    def __init__(self, switch_id, blnet_id, comm):
        """Initialize the switch."""
        self._blnet_id = blnet_id
        self._id = switch_id
        self.communication = comm
        self._name = '{} automated'.format(blnet_id)
        self._friendly_name = blnet_id
        self._state = STATE_UNKNOWN
        self._activation_state = self._state
        self._assumed_state = True
        self._mode = STATE_UNKNOWN
        self._fullmode = STATE_UNKNOWN
        self._icon = None
        self._last_updated = None

    def update(self):
        """Get the latest data from communication device """
        # check if new data has arrived
        last_blnet_update = self.communication.last_updated()

        if last_blnet_update == self._last_updated:
            return

        sensor_data = self.communication.data.get(self._blnet_id)

        if sensor_data is None:
            return

        self._friendly_name = "{} automated".format(
            sensor_data.get('friendly_name'))
        if sensor_data.get('mode') == 'HAND':
            self._state = 'off'
            if sensor_data.get('value') == 'EIN':
                self._icon = 'mdi:cog-outline'
            else:
                self._icon = 'mdi:cog-off-outline'
            self._mode = 'HAND'
        else:
            self._state = 'on'
            if sensor_data.get('value') == 'EIN':
                self._mode = 'EIN'
                self._icon = 'mdi:cog'
            elif sensor_data.get('value') == 'AUS':
                self._mode = 'AUS'
                self._icon = 'mdi:cog-off'
            else:
                self._mode = 'unbekannt'
                self._icon = 'mdi:cog-refresh-outline'
        
        self._activation_state = sensor_data.get('value')

        self._fullmode = sensor_data.get('mode') + '/' + sensor_data.get('value')
        self._last_updated = last_blnet_update
        self._assumed_state = False

    @property
    def name(self):
        """Return the name of the switch."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def icon(self):
        """Return the state of the device."""
        return self._icon

    @property
    def device_state_attributes(self):
        """Return the state attributes of the device."""
        attrs = {}
        attrs[MODE] = self._mode
        attrs[FULLMODE] = self._fullmode
        attrs[FRIENDLY_NAME] = self._friendly_name
        return attrs

    @property
    def is_on(self):
        """Return true if device is on."""
        return self._state

    def turn_on(self, **kwargs):
        """Turn the device on."""
        self.communication.turn_auto(self._id)
        self._state = 'on'
        self._assumed_state = True

    def turn_off(self, **kwargs):
        """Turn the device off."""
        if self._activation_state == 1:
            self.communication.turn_on(self._id)
        else:
            self.communication.turn_off(self._id)
        self._state = 'off'
        self._assumed_state = True

    @property
    def assumed_state(self)->bool:
        return self._assumed_state

(moved from repository ha-config, created by @Bullischorsch)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.