Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request HA/mqtt_payload_processor!19
  • Loading branch information
Daniel Mason committed Sep 22, 2020
2 parents fe652aa + 3ecb182 commit 7f65801
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
11 changes: 5 additions & 6 deletions custom_components/mqtt_code/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# E.g. RF codes, Bluetooth ids, etc.

# Documentation: https://github.com/danobot/mqtt_payload_processor
# Version: v2.0.2
# Version: v2.0.3

import homeassistant.loader as loader
import logging
Expand Down Expand Up @@ -293,7 +293,7 @@ def process(self, payload):
# for k in j.keys():
# self.log.debug("%s %s" % (k, j[k]))
value = j["value"]
self.log.debug("Is %s a match for %s?" % (value, self.name))
# self.log.debug("Is %s a match for %s?" % (value, self.name))
for p in self.payloads_on:
if int(p) == value:
self.log.info("Processing %s on code" % (p))
Expand All @@ -311,10 +311,9 @@ def process(self, payload):
def message_received(self, message):
"""Handle new MQTT messages."""

self.log.debug("Message received: " + str(message))
# self.log.debug("Message received: " + str(message))

self.process(message.payload)
self.log.debug("after process")


def update_state(self, payload, action):
Expand Down Expand Up @@ -344,8 +343,8 @@ def update_state(self, payload, action):
def handleRFCode(self, action):
# self.hass.states.set(DOMAIN + '.last_triggered_by', self.name)
# hass.states.set('rf_processor.last_triggered_time', time.localtime(time.time()))
self.log.debug("event: " + str(self.event))
self.log.debug("globalEvent: " + str(self.globalEvent))
# self.log.debug("event: " + str(self.event))
# self.log.debug("globalEvent: " + str(self.globalEvent))
self.device.handle_event(self)
if self.event or self.globalEvent:
self.log.debug("Sending event.")
Expand Down
5 changes: 3 additions & 2 deletions custom_components/processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import logging
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
# from homeassistant.compoennts.alert import Alert
_LOGGER = logging.getLogger(__name__)
VERSION = '2.0.1'
VERSION = '2.0.3'

DEPENDENCIES = ['mqtt']

Expand Down Expand Up @@ -105,4 +106,4 @@ def state_attributes(self):
return None




15 changes: 11 additions & 4 deletions custom_components/processor/yaml_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import logging;
from datetime import datetime, timedelta, date, time
import homeassistant.helpers.script as script
from homeassistant.core import Context
from . import DOMAIN
_LOGGER = logging.getLogger(__name__)
from homeassistant.util import dt
VERSION='2.0.2'
VERSION='2.0.3'
class Scheduler:

def __init__(self, yaml):
Expand Down Expand Up @@ -40,7 +42,7 @@ def __init__(self, mapping, name, args):
# super(Action,self).__init__(self.hass,'processor-action' + name,name,args)
self.log = logging.getLogger("{}.actions.{}".format(mapping.log.name, name))
self.log.info("Creating action " + name)
if 'name' is None:
if name is None:
self.log.error("Missing name in Action")
self.schedule_name = name
self.log.debug("Script Sequence: " + str(args))
Expand Down Expand Up @@ -71,9 +73,14 @@ def execute(self, schedule): ## passed in call-back function
if self.schedule_name == schedule:
self.log.debug("Executing actions in Action {}".format(self.schedule_name))
try:
script.Script.call_from_config(self.mapping.device.hass, self._script_config)
except Exception as e:
# self.log.error(str(dir(script)))
# self.log.error(str(dir(script.service)))
s = script.Script(self.mapping.device.hass, self._script_config, self.schedule_name, DOMAIN)
context = Context(parent_id="device.%s" % (self.mapping.device.name), id="actions.{}".format( self.schedule_name))
s.run(context=context)
except Exception as e:
self.log.error("Error calling supplied script: " + str(e))
raise e



Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "Processor",
"homeassistant": "0.103.2"
"homeassistant": "0.115.1"
}

0 comments on commit 7f65801

Please sign in to comment.