Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
Update the README
Sort the manifest
Advance to version 0.9.2
  • Loading branch information
gicamm committed Feb 24, 2023
1 parent 8b7e8e5 commit 1071a8a
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 46 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Loads default set of integrations. Do not remove.
default_config:

logger:
default: info
logs:
custom_components.comelit: debug

comelit:
hub:
host: X.X.X.X
port: 1883
mqtt-user: hsrv-user
mqtt-password: sf1nE9bjPc
username: comelithub
password: xxxxxxxx
serial: xxxxxxxxxxxxx
client: homeassistant
scan_interval: 2
vedo:
host: X.X.X.X
port: 80
password: xxxxxx
scan_interval: 30
13 changes: 13 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '2.4'

services:
homeassistant:
image: homeassistant/home-assistant:latest
container_name: homeassistant
networks:
default: { }
ports:
- "8123:8123"
volumes:
- ../custom_components/comelit:/config/custom_components/comelit
- ./configuration.yaml:/config/configuration.yaml
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*venv
.coverage
.idea
.venv
.vscode/
__pycache__
pythonenv*
venv/
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ comelit:
#### Comelit app
- Open the Comelit app
- Scan for a new hub device
- Copy the serial
- Copy the serial (remove all non-numeric characters, i.e. 'hsrv-0123456789' -> '0123456789' )

For more information, see the [Wiki](https://github.com/gicamm/homeassistant-comelit/wiki).

Expand All @@ -44,6 +44,7 @@ For more information, see the [Wiki](https://github.com/gicamm/homeassistant-com
- Shutters
- Energy Production
- Energy Consumption
- Clima
- Temperature/Humidity
- Automation
- Scenario
Expand Down Expand Up @@ -78,28 +79,40 @@ Below is an example with lovelace:
- entity: sensor.comelit_power_cons
name: Consume

# door lock
# door lock
- entity: scene.comelit_doorlock
name: Door lock
icon: mdi:key

# clima
- entity: switch.comelit_switch_clima
name: Clima
# switch
- entity: switch.comelit_switch1
name: Switch1

# humidity
# clima
- entity: climate.comelit_bathroom
name: Bathroom
- entity: climate.comelit_living
name: Living

# humidity
- entity: sensor.comelit_humidity_bathroom
name: Bathroom
- entity: sensor.comelit_humidity_living
name: Living

# shutters
# temperature
- entity: sensor.comelit_temperature_bathroom
name: Bathroom
- entity: sensor.comelit_temperature_living
name: Living

# shutters
- entity: cover.comelit_living
name: Living
- entity: cover.comelit_kitchen_sx
name: Kitchen

# vedo Alarm
# vedo Alarm
- entity: binary_sensor.comelit_vedo_garage
name: Garage
- entity: alarm_control_panel.comelit_vedo_garage
Expand Down
6 changes: 3 additions & 3 deletions custom_components/comelit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Comelit Hub/Vedo integration."""
"""Comelit SimpleHome/Vedo integration."""

import logging
import voluptuous as vol
Expand Down Expand Up @@ -39,7 +39,7 @@ def setup(hass, config):
hass.data[DOMAIN] = {}
hass.data[DOMAIN]['conf'] = conf

# Comelit Hub
# Comelit SimpleHome Hub
if 'hub' in conf:
hub_conf = conf["hub"]
if hub_conf is not None:
Expand All @@ -62,7 +62,7 @@ def setup(hass, config):
hass.helpers.discovery.load_platform('scene', DOMAIN, {}, config)
hass.helpers.discovery.load_platform('switch', DOMAIN, {}, config)
hass.helpers.discovery.load_platform('climate', DOMAIN, {}, config)
_LOGGER.info("Comelit Hub integration started")
_LOGGER.info("Comelit SimpleHome integration started")

# Comelit Vedo
if 'vedo' in conf:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/comelit/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
_LOGGER = logging.getLogger(__name__)



def setup_platform(hass, config, add_entities, discovery_info=None):
hass.data[DOMAIN]['hub'].climate_add_entities = add_entities
_LOGGER.info("Comelit Climate Integration started")


class ComelitClimate(ComelitDevice, ClimateEntity):
def __init__(self, id, description, state_dict, hub):
ComelitDevice.__init__(self, id, "climate", description)
Expand Down
21 changes: 6 additions & 15 deletions custom_components/comelit/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,14 @@ def dispatch(self, payload):
try:
req_type = payload["req_type"]

if req_type == RequestType.STATUS:
_LOGGER.debug(f"Dispatching {payload}")
else:
_LOGGER.info(f"Dispatching {payload}")

options = {
RequestType.ANNOUNCE: self.manage_announce,
RequestType.LOGIN: self.token,
RequestType.STATUS: self.status,
RequestType.PARAMETERS: self.parse_parameters,
}

# I'm not 100% sure what these do, and I'm not sure why I wasn't seeing errors before.
# discard unrecognized types
if req_type in options:
options[req_type](payload)
except Exception as e:
Expand All @@ -254,7 +249,7 @@ def dispatch(self, payload):

def manage_announce(self, payload):
self.agent_id = payload['out_data'][0]["agent_id"]
_LOGGER.debug("agent id is %s", self.agent_id)
_LOGGER.debug("Announce. Agent id is %s", self.agent_id)
req = {"req_type": RequestType.LOGIN, "req_sub_type": -1, "agent_type": 0, "user_name": self.hub_user,
"password": self.hub_password}
self.publish(req)
Expand Down Expand Up @@ -498,21 +493,25 @@ def update_entities(self, elements):
_LOGGER.error(e)

def status(self, payload):
_LOGGER.debug(f"Dispatching status {payload}")
try:
elements = payload["out_data"][0][HubFields.ELEMENTS]
self.update_entities(elements)
except Exception as e:
_LOGGER.error("Status error")
_LOGGER.error(e)


def update_status(hub):
try:
_LOGGER.debug("Publishing the status request")
req = {"req_type": RequestType.STATUS, "req_sub_type": -1, "obj_id": "GEN#17#13#1", "detail_level": 1}
hub.publish(req)
except Exception as e:
_LOGGER.error("Error updating status")
_LOGGER.error(e)


# Make a request for status
class StatusUpdater (Thread):
def __init__(self, name, scan_interval, hub):
Expand All @@ -528,14 +527,6 @@ def run(self):
if self.hub.sessiontoken == "":
continue

# optiluca: does not do anything?
'''
if parameters_timer == 0:
{"req_type": 8, "seq_id": 5, "req_sub_type": 23, "param_type": 2, "agent_type": 0,
"sessiontoken": "1367343208"}
parameters_timer = 30
'''

update_status(self.hub)
time.sleep(self._scan_interval)
# parameters_timer = parameters_timer - 1
Expand Down
1 change: 0 additions & 1 deletion custom_components/comelit/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def turn_on(self, **kwargs):
self._state = STATE_ON # Immediately update the state, don't wait for the next update
self.schedule_update_ha_state()


def turn_off(self, **kwargs):
self._light.light_off(self._id)
self._state = STATE_OFF # Immediately update the state, don't wait for the next update
Expand Down
34 changes: 17 additions & 17 deletions custom_components/comelit/manifest.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"domain": "comelit",
"name": "Comelit SimpleHome/Vedo",
"documentation": "https://github.com/gicamm/homeassistant-comelit/wiki",
"issue_tracker": "https://github.com/gicamm/homeassistant-comelit/issues",
"dependencies": [],
"codeowners": [
"@gicamm"
],
"requirements": [
"requests",
"paho-mqtt",
"wrapt_timeout_decorator"
],
"iot_class": "local_push",
"quality_scale": "silver",
"version": "0.9.1",
"config_flow": false
"domain": "comelit",
"name": "Comelit SimpleHome/Vedo",
"codeowners": [
"@gicamm"
],
"config_flow": false,
"dependencies": [],
"documentation": "https://github.com/gicamm/homeassistant-comelit/wiki",
"iot_class": "local_push",
"issue_tracker": "https://github.com/gicamm/homeassistant-comelit/issues",
"quality_scale": "silver",
"requirements": [
"requests",
"paho-mqtt",
"wrapt_timeout_decorator"
],
"version": "0.9.2"
}
16 changes: 16 additions & 0 deletions test/mqtt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## SUB
mosquitto_sub -v -h $IP -p $PORT -u "hsrv-user" -P "sf1nE9bjPc" -t 'HSrv/$SERIAL/tx/test'


## LOGIN
mosquitto_pub -h $IP -p $PORT -u "hsrv-user" -P "sf1nE9bjPc" -t 'HSrv/$SERIAL/rx/gc' -m '{"req_type": RequestType.LOGIN, "req_sub_type": -1, "agent_type": 0, "user_name": $USERNAME,"password": $PWD}'



Read the session ID from the response
HSrv/$SERIAL/tx/gc {"req_type":5,"req_sub_type":-1,"seq_id":0,"req_result":0,"uid":".....","sessiontoken":"......"}

Then use that session ID for publishing messages

#Turn light ON
mosquitto_pub -h $IP -p $PORT -u "hsrv-user" -P "sf1nE9bjPc" -t 'HSrv/$SERIAL/rx/gc' -m '{"req_type": 1, "req_sub_type": 3, "obj_id": "DOM#LT#24.1", "act_type": 0, "act_params": [1], "seq_id": 8321, "agent_id": 10, "sessiontoken": "....."}''

0 comments on commit 1071a8a

Please sign in to comment.