Skip to content

Commit 7f65801

Browse files
author
Daniel Mason
committed
Merge branch 'develop' into 'master'
Develop See merge request HA/mqtt_payload_processor!19
2 parents fe652aa + 3ecb182 commit 7f65801

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

custom_components/mqtt_code/processor.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# E.g. RF codes, Bluetooth ids, etc.
66

77
# Documentation: https://github.com/danobot/mqtt_payload_processor
8-
# Version: v2.0.2
8+
# Version: v2.0.3
99

1010
import homeassistant.loader as loader
1111
import logging
@@ -293,7 +293,7 @@ def process(self, payload):
293293
# for k in j.keys():
294294
# self.log.debug("%s %s" % (k, j[k]))
295295
value = j["value"]
296-
self.log.debug("Is %s a match for %s?" % (value, self.name))
296+
# self.log.debug("Is %s a match for %s?" % (value, self.name))
297297
for p in self.payloads_on:
298298
if int(p) == value:
299299
self.log.info("Processing %s on code" % (p))
@@ -311,10 +311,9 @@ def process(self, payload):
311311
def message_received(self, message):
312312
"""Handle new MQTT messages."""
313313

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

316316
self.process(message.payload)
317-
self.log.debug("after process")
318317

319318

320319
def update_state(self, payload, action):
@@ -344,8 +343,8 @@ def update_state(self, payload, action):
344343
def handleRFCode(self, action):
345344
# self.hass.states.set(DOMAIN + '.last_triggered_by', self.name)
346345
# hass.states.set('rf_processor.last_triggered_time', time.localtime(time.time()))
347-
self.log.debug("event: " + str(self.event))
348-
self.log.debug("globalEvent: " + str(self.globalEvent))
346+
# self.log.debug("event: " + str(self.event))
347+
# self.log.debug("globalEvent: " + str(self.globalEvent))
349348
self.device.handle_event(self)
350349
if self.event or self.globalEvent:
351350
self.log.debug("Sending event.")

custom_components/processor/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import logging
88
from homeassistant.helpers.entity_component import EntityComponent
99
from homeassistant.helpers.entity import Entity
10+
# from homeassistant.compoennts.alert import Alert
1011
_LOGGER = logging.getLogger(__name__)
11-
VERSION = '2.0.1'
12+
VERSION = '2.0.3'
1213

1314
DEPENDENCIES = ['mqtt']
1415

@@ -105,4 +106,4 @@ def state_attributes(self):
105106
return None
106107

107108

108-
109+

custom_components/processor/yaml_scheduler.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import logging;
22
from datetime import datetime, timedelta, date, time
33
import homeassistant.helpers.script as script
4+
from homeassistant.core import Context
5+
from . import DOMAIN
46
_LOGGER = logging.getLogger(__name__)
57
from homeassistant.util import dt
6-
VERSION='2.0.2'
8+
VERSION='2.0.3'
79
class Scheduler:
810

911
def __init__(self, yaml):
@@ -40,7 +42,7 @@ def __init__(self, mapping, name, args):
4042
# super(Action,self).__init__(self.hass,'processor-action' + name,name,args)
4143
self.log = logging.getLogger("{}.actions.{}".format(mapping.log.name, name))
4244
self.log.info("Creating action " + name)
43-
if 'name' is None:
45+
if name is None:
4446
self.log.error("Missing name in Action")
4547
self.schedule_name = name
4648
self.log.debug("Script Sequence: " + str(args))
@@ -71,9 +73,14 @@ def execute(self, schedule): ## passed in call-back function
7173
if self.schedule_name == schedule:
7274
self.log.debug("Executing actions in Action {}".format(self.schedule_name))
7375
try:
74-
script.Script.call_from_config(self.mapping.device.hass, self._script_config)
75-
except Exception as e:
76+
# self.log.error(str(dir(script)))
77+
# self.log.error(str(dir(script.service)))
78+
s = script.Script(self.mapping.device.hass, self._script_config, self.schedule_name, DOMAIN)
79+
context = Context(parent_id="device.%s" % (self.mapping.device.name), id="actions.{}".format( self.schedule_name))
80+
s.run(context=context)
81+
except Exception as e:
7682
self.log.error("Error calling supplied script: " + str(e))
83+
raise e
7784

7885

7986

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "Processor",
3-
"homeassistant": "0.103.2"
3+
"homeassistant": "0.115.1"
44
}

0 commit comments

Comments
 (0)