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

Added Loxone plattform #9706

Closed
wants to merge 24 commits into from
Closed

Added Loxone plattform #9706

wants to merge 24 commits into from

Conversation

JoDehli
Copy link

@JoDehli JoDehli commented Oct 5, 2017

Description:

First real integration of the Loxone Miniserver.

Example entry for configuration.yaml (if applicable):

#For the connection over Websocket to the Miniserver
loxone:
  username: !secret loxoneuser
  password: !secret loxonepassword
  host: 192.168.1.225
  port: 8080

#Simple analog sensor
sensor loxone:
  - platform: loxone
    uuid: "0dc8ca55-010c-1f6d-ffff403fb0c34b9e"
    unit_of_measurement: km/h
    sensorname: Windspeed
    sensortyp: InfoOnlyAnalog

#An automation example for sending values to the loxone with the loxone.event_websocket_command service
  - platform: template
    switches:
      plug_tv:
        friendly_name: ""
        value_template: "{{ is_state('sensor.plug_tv', 'on') }}"
        turn_on:
          service: loxone.event_websocket_command
          data:
            uuid: '0f14d364-00c4-63c2-ffff403fb0c34b9e'
            value: 'Pulse'
        turn_off:
          service: loxone.event_websocket_command
          data:
            uuid: '0f14d38c-0127-92a1-ffff403fb0c34b9e'
            value: 'Pulse'

Checklist:

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
    script/gen_requirements_all.py.

@homeassistant
Copy link
Contributor

Hi @JoDehli,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

fields[1] + "-" + \
fields[2] + "-" + \
fields[3] + \
fields[4]

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

uuidstr = fields[0] + "-" + \
fields[1] + "-" + \
fields[2] + "-" + \
fields[3] + \

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = fields[0] + "-" + \
fields[1] + "-" + \
fields[2] + "-" + \

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

event_uuid = uuid.UUID(bytes_le=packet[0:16])
fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = fields[0] + "-" + \
fields[1] + "-" + \

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

_LOGGER.debug(parsed_data)
self._hass.bus.async_fire(EVENT, parsed_data)

@asyncio.coroutine

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

try:
if not self._ws:
self._ws = yield from wslib.connect(
"ws://{}:{}/ws/rfc6455".format(self._host, self._port), timeout=5)

Choose a reason for hiding this comment

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

line too long (86 > 79 characters)

:param device_uuid: Device id of a sensor or input
:param value: Value to be sent
"""
yield from self._ws.send("jdev/sps/io/{}/{}".format(device_uuid, value))

Choose a reason for hiding this comment

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

line too long (80 > 79 characters)

device_uuid = call.data.get(ATTR_UUID, DEFAULT)
yield from api.send_websocket_command(device_uuid, value)

hass.services.async_register(DOMAIN, 'event_websocket_command', handle_websocket_command)

Choose a reason for hiding this comment

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

line too long (93 > 79 characters)

data = {device_uuid: value}
hass.bus.async_fire(EVENT, data)

hass.services.async_register(DOMAIN, 'event_bus_command', handle_event_bus_command)

Choose a reason for hiding this comment

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

line too long (87 > 79 characters)


import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (CONF_HOST, CONF_PORT, CONF_USERNAME, CONF_PASSWORD)

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

event_uuid = uuid.UUID(bytes_le=packet[0:16])
fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = fields[0] + "-" + fields[1] + "-" + fields[2] + "-" + \
fields[3] + fields[4]

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

Copy link
Member

Choose a reason for hiding this comment

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

String formatting -> "".format()

@JoDehli
Copy link
Author

JoDehli commented Oct 5, 2017

Hello everybody,

can somebody help me to fix this errors? I think most of them are code styling problems.
I also need a documentation page on the github site of Home-Assistant. How do I do that.

Thanks for your help.

Jojo

Copy link
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

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

Just a couple of quick comments.


def __init__(self, name, uuid, sensor_typ, unit_of_measurement):
"""Initialize the sensor."""
self._state = 0.0
Copy link
Member

Choose a reason for hiding this comment

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

Set it to None and let Home Assistant handle the rest.

EVENT = 'loxone_received'

_LOGGER = logging.getLogger(__name__)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Done

Loxone simple sensor

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/loxone/
Copy link
Member

Choose a reason for hiding this comment

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

Needs to point to the sensor documentation.

event_uuid = uuid.UUID(bytes_le=packet[0:16])
fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = fields[0] + "-" + fields[1] + "-" + fields[2] + "-" + \
fields[3] + fields[4]
Copy link
Member

Choose a reason for hiding this comment

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

String formatting -> "".format()

"""
key_dict = json.loads(key)
key_value = key_dict['LL']['value']
data = username + ":" + password
Copy link
Member

Choose a reason for hiding this comment

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

String formatting.

:param user: Username to communicate with the Miniserver
:param password: Password of the user
:param host: Address where the Loxone Miniserver runs
:param port: Port of the Loxone Miniserver on the host
Copy link
Member

Choose a reason for hiding this comment

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

Please replace the parameter with a simple docstring.

Main class for the communication with the miniserver
"""

# pylint: disable=too-many-arguments, too-many-instance-attributes
Copy link
Member

Choose a reason for hiding this comment

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

Those are already disabled globally.

"""
Loxone Gateway
Main class for the communication with the miniserver
"""
Copy link
Member

Choose a reason for hiding this comment

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

Please go for an one-line docstring.

_LOGGER = logging.getLogger(__name__)

DOMAIN = 'loxone'
DEFAULT_HOST = '127.0.0.1'
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't make much sense. Or isn't the Miniserver an independent hardware unit only?

CONF_PASSWORD)
from homeassistant.helpers.event import async_track_time_interval

REQUIREMENTS = ['websockets==3.2']
Copy link
Member

Choose a reason for hiding this comment

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

If needed then you could go with websockets 3.4. I guess that we haven't update the requirement because it's not heavily used.

@fabaff
Copy link
Member

fabaff commented Oct 6, 2017

I also need a documentation page on the github site of Home-Assistant. How do I do that.

https://home-assistant.io/developers/website/

Please check the list in the PR template.

ATTR_UUID = 'uuid'
ATTR_VALUE = 'value'

@asyncio.coroutine

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

@JoDehli
Copy link
Author

JoDehli commented Oct 6, 2017

Hello fabaff,

can you help with the documentation and the errors for the "The Travis CI build"?
This is my first work with git and such tools.

Thanks in advance.

Jojo

Copy link
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

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

You need to pull the latest changes dev into your local branch and the run gen_requirements_all.py

Again, the checklist in the PR template is there to help.

CONF_SENSOR_TYP = 'sensortyp'
CONF_UUID = 'uuid'

CONFIG_SCHEMA = vol.Schema({
Copy link
Member

Choose a reason for hiding this comment

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

You have to extend the sensor validation. Get the details from the link I provided in the previous comment about the configuration validation.

CONF_PASSWORD)
from homeassistant.helpers.event import async_track_time_interval

REQUIREMENTS = ['websockets==3.4']
Copy link
Member

Choose a reason for hiding this comment

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

You need to update the requirement of the other platform that uses websockets as well.

Copy link
Author

Choose a reason for hiding this comment

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

I think my biggest problem is that I do not know how to pull the latest changes from dev.
I tried it without a gui for github but I did not get it to work. Now I tried GitKraken. I fixed all of
the pylint issues. Maybe it is better you delete my pull request and I delete my fork. And I first try to get used with github and git.

Copy link
Author

Choose a reason for hiding this comment

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

And also I have big problems with the documentation page. But this is also a problem because I do not understand the github way to do it. I work personally with subversion and this is much easier for me. I believe that git is better but also more complicated.

password = config[DOMAIN][CONF_PASSWORD]
host = config[DOMAIN][CONF_HOST]
port = config[DOMAIN][CONF_PORT]
api = LoxoneGateway(hass, user, password, host, port)
Copy link
Member

Choose a reason for hiding this comment

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

Will there be no exception if something is worn with the connection?



class LoxoneGateway:
""" Main class for the communication with the miniserver """
Copy link
Member

Choose a reason for hiding this comment

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

See PEP257 for details about proper docstrings and the docs about testing them.

event_uuid = uuid.UUID(bytes_le=packet[0:16])
fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = "{}-{}-{}-{}{}".format(fields[0], fields[1], fields[2],
fields[3], fields[4])

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

event_uuid = uuid.UUID(bytes_le=packet[0:16])
fields = event_uuid.urn.replace("urn:uuid:", "").split("-")
uuidstr = "{}-{}-{}-{}{}".format(fields[0], fields[1], fields[2],
fields[3], fields[4])

Choose a reason for hiding this comment

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

continuation line over-indented for visual indent

For more details about this component, please refer to the documentation at
https://home-assistant.io/components/loxone/
"""
# pylint: disable=unused-import, too-many-lines
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not disable pylint

Copy link
Contributor

@andrey-git andrey-git left a comment

Choose a reason for hiding this comment

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

Please add yourself as owner in https://github.com/home-assistant/home-assistant/blob/dev/CODEOWNERS for the new files.

The requirements files seem out of sync.

@fabaff
Copy link
Member

fabaff commented Oct 13, 2017

Please exclude homeassistant/components/frontend/www_static/home-assistant-polymer from your commits.

@JoDehli
Copy link
Author

JoDehli commented Oct 14, 2017

Hello fabaff,
I want to delete my pull request. I can not get used to with git and git hub.
Can you delete the pull request. Than I delete my source. Maybe someone else will create a binding.

Thanks.

@fabaff
Copy link
Member

fabaff commented Oct 23, 2017

I guess that you can close the PR by yourself.

Please consider to move forward with this PR as you are close to the finish line.

@xAPPO
Copy link

xAPPO commented Oct 25, 2017

@JoDehli You sound frustrated but just to say I really do hope you persevere and successfully commit this into Home Assistant. I have a couple of Loxone servers and am really interested in this capability.
Kevin

@JoDehli
Copy link
Author

JoDehli commented Oct 25, 2017

Sorry but I deleted my repository. I switch to Node-Red. There you can find a good binding for the Loxone.
Git is too complicated for me ;-)

@JoDehli JoDehli closed this Oct 25, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Mar 3, 2018
@ghost ghost removed the platform: sensor.loxone label Mar 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants