Skip to content

Commit

Permalink
Merge pull request #10 from kevinkk525/dev
Browse files Browse the repository at this point in the history
Update Version 6.0.0

* [easyGPIO] topics now use "easyGPIO" to not make them not collide with module "switches.GPIO"
* [remoteSensors] use remote sensors as if they were locally connected
* [remoteSwitch] use a remote switch as if it was locally connected
* [COMPONENTS] extended API significantly, updated to new/changed MQTT features, added cleanup method
* [SENSOR COMPONENT] major base class for a unified sensor API and features to make usage and development easier
* [Sensors] updated all sensors to use the new SENSOR COMPONENT. Some sensors therefore experience breaking changes in configuration, default topics and behaviour.
* [DS18] rewritten for new sensor API
* [HEATER] removed deprecated component
* [CLIMATE] added new Climate component which is compatible to homeassistant MQTT Climate
* [CONFIG] removed option to load components from .json files, use components.py instead
* [STATS] Major update, publishing many device stats as hass json_attributes and RSSI as main value instead of "online/offline" which is now done directly in mqtt as availability topic. Published values: (last_boot, uptime, pysmartnode version, micropython firmware version, RAM free, RSSI, MQTT Downtime, MQTT Reconnects, Asyncio waitq used size)
* [MQTT] Improvements, Subscriptions done by mqtt not by components, Subscribing uses subscription chain and can be called non-blocking synchronously, added easy way to restore a device state from a state topic of a subscribed command_topic, prevention of uasyncio queue overflows when receiving too many messages
* [LOGGING] Extended asyncLog() method with kwargs "timeout" and "await_connection" just like mqtt.publish
* [LOGGING] Now works similar to print expecting multiple args instead of one message string. Optimizes RAM usage (especially with local_only logging).
* [TOOLS] updated esp8266 build scripts, script to strip variable type hints as those are not yet supported by micropython
* [CONFIG] config.py update, made configuration easier and smaller by freezing standard values in ROM and custom configs in config.py will just overwrite those.
  • Loading branch information
kevinkk525 authored Nov 7, 2019
2 parents f853efb + f6ec71f commit 4b88ec0
Show file tree
Hide file tree
Showing 143 changed files with 5,756 additions and 3,781 deletions.
193 changes: 72 additions & 121 deletions README.md

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
gc.collect()

_heater = None
_component_name = "heater"
_component_type = "sensor"
COMPONENT_NAME = "heater"
_COMPONENT_TYPE = "sensor"


class Heater(Component):
Expand Down Expand Up @@ -116,19 +116,19 @@ def __init__(self, TEMP_SENSOR, REACTION_TIME, HYSTERESIS_LOW, HYSTERESIS_HIGH,

async def _discovery(self):
name = "heater_target_temp"
await self._publishDiscovery(_component_type, self.__target_temp_cmd_topic[:-4], name, DISCOVERY_SWITCH,
await self._publishDiscovery(_COMPONENT_TYPE, self.__target_temp_cmd_topic[:-4], name, DISCOVERY_SWITCH,
self._frn_temp or " Target Temperature")
gc.collect()
name = "heater_mode"
await self._publishDiscovery(_component_type, self.__mode_cmd_topic[:-4], name, DISCOVERY_SWITCH,
await self._publishDiscovery(_COMPONENT_TYPE, self.__mode_cmd_topic[:-4], name, DISCOVERY_SWITCH,
self._frn_mode or "Mode")
gc.collect()
name = "heater_power"
await self._publishDiscovery(_component_type, self.__power_topic, name, "",
await self._publishDiscovery(_COMPONENT_TYPE, self.__power_topic, name, "",
self._frn_power or "Power")
gc.collect()
name = "heater_status"
await self._publishDiscovery(_component_type, self.__status_topic, name, "",
await self._publishDiscovery(_COMPONENT_TYPE, self.__status_topic, name, "",
self._frn_status or "Power")
gc.collect()

Expand Down Expand Up @@ -213,8 +213,8 @@ def setLastError(self, error):
def getLastError(self):
return self.__last_error

async def _init(self):
await super()._init()
async def _init_network(self):
await super()._init_network()
await log.asyncLog("info", "Heater Core version {!s}".format(__version__))
if self.__initializeHardware is not None:
await self.__initializeHardware()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, HEATER: Heater = None, ACTIVE=False):
if ACTIVE is True:
self._heater.setMode("", "REMOTE", False)

async def _init(self):
await super()._init()
async def _init_network(self):
await super()._init_network()
await log.asyncLog("info", "Heater mode 'remoteControl' version {!s}".format(__version__))

async def _requestPower(self, topic, msg, retain):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def __init__(self, HEATER: Heater = None, NIGHT_TIME_TOPIC=None, DAY_TIME_TOPIC=
self._subscribe(self.NIGHT_TEMP_TOPIC, self._setNightTemp)
self._subscribe(self.DAY_TEMP_TOPIC, self._setDayTemp)

async def _init(self):
async def _init_network(self):
await log.asyncLog("info", "Heater plugin 'daynight' version {!s}".format(__version__))
await super()._init()
await super()._init_network()

async def _daynight(self, heater, data):
if self.__time_day is None or self.__time_night is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
@author: Kevin Köck
'''

__version__ = "0.1"
__updated__ = "2018-09-25"
__version__ = "0.2"
__updated__ = "2018-10-17"

from pysmartnode.utils import sys_vars
import ujson
Expand All @@ -21,7 +21,7 @@ def _importComponents(_log):
_log.critical("components.py does not exist")
return False
except Exception as e:
_log.ciritcal("components.py: {!s}".format(e))
_log.critical("components.py: {!s}".format(e))
return False
if hasattr(components, "COMPONENTS"):
_log.info("Trying to register COMPONENTS of components.py", local_only=True)
Expand All @@ -31,7 +31,7 @@ def _importComponents(_log):
return True


async def loadComponentsFile(_log, registerComponentsAsync):
async def loadComponentsFile(_log, registerComponent):
if not sys_vars.hasFilesystem():
comps = _importComponents(_log)
if comps is False:
Expand All @@ -58,12 +58,10 @@ async def loadComponentsFile(_log, registerComponentsAsync):
f.close()
gc.collect()
for component in order:
tmp = {"_order": [component]}
try:
f = open("components/{!s}.json".format(component), "r")
tmp[component] = ujson.loads(f.read())
f.close()
await registerComponentsAsync(tmp)
with open("components/{!s}.json".format(component), "r") as f:
componentdata = ujson.load(f)
registerComponent(component, componentdata)
except Exception as e:
_log.error("Error loading component file {!s}, {!s}".format(component, e))
gc.collect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ async def _receiveConfig(log):
_pyconfig._components = awaitConfig
# mqtt not fully initialized when class was created created
for i in range(1, 4):
await _mqtt.subscribe("{!s}/login/{!s}".format(_mqtt.mqtt_home, _mqtt.client_id), qos=1,
check_retained_state_topic=False)
await _mqtt.subscribe("{!s}/login/{!s}".format(_mqtt.mqtt_home, _mqtt.client_id), qos=1)
log.debug("waiting for config", local_only=True)
await _mqtt.publish("{!s}/login/{!s}/set".format(_mqtt.mqtt_home, _mqtt.client_id), _pyconfig.VERSION, qos=1)
t = time.ticks_ms()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def printMemory(info=""):
def creating():
gc.collect()
printMemory("Start")
from pysmartnode.utils.subscriptionHandlers.subscribe_file import SubscriptionHandler
from _deprecated.subscriptionHandlers import SubscriptionHandler
gc.collect()
printMemory("After import")
global handler
Expand Down Expand Up @@ -67,7 +67,7 @@ def speedtest():


def test():
from pysmartnode.utils.subscriptionHandlers.subscribe_file import SubscriptionHandler
from _deprecated.subscriptionHandlers import SubscriptionHandler
handler = SubscriptionHandler()

@timeit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def printMemory(info=""):
def creating():
gc.collect()
printMemory("Start")
from pysmartnode.utils.subscriptionHandlers.subscription import SubscriptionHandler
from _deprecated.subscriptionHandlers import SubscriptionHandler
gc.collect()
printMemory("After import")
global handler
Expand Down Expand Up @@ -96,7 +96,7 @@ def speedtest():


def test():
from pysmartnode.utils.subscriptionHandlers.subscription import SubscriptionHandler
from _deprecated.subscriptionHandlers import SubscriptionHandler
handler = SubscriptionHandler()
handler.addObject("home/test/htu", "func1")
handler.addObject("home/test2/htu", "func2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def wrapResult(handler, expected, result):
print(handler, "Success:", equals, "Expected result:", expected, "Result:", result)


from pysmartnode.utils.subscriptionHandlers.tree import Tree
from pysmartnode.utils.subscriptionHandlers.subscribe_file import SubscriptionHandler as SubscriptionHandler_File
from pysmartnode.utils.subscriptionHandlers.subscription import SubscriptionHandler
from _deprecated.subscriptionHandlers import Tree
from _deprecated.subscriptionHandlers import SubscriptionHandler as SubscriptionHandler_File
from _deprecated.subscriptionHandlers import SubscriptionHandler

for handler in [Tree, SubscriptionHandler, SubscriptionHandler_File]:
print(handler)
Expand Down
4 changes: 2 additions & 2 deletions _testing/utils/tree.py → _deprecated/testing/utils/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def printMemory(info=""):

def functional_testing():
print("Functioncal test")
from pysmartnode.utils.subscriptionHandlers.tree import Tree
from _deprecated.subscriptionHandlers import Tree
tree = Tree("home", ["Functions"])
tree.addObject("home/1325/htu21d/set", "func1")
tree.addObject("home/1325/#", "funcWildcard")
Expand Down Expand Up @@ -72,7 +72,7 @@ def functional_testing():
def creating():
gc.collect()
printMemory("Start")
from pysmartnode.utils.subscriptionHandlers.tree import Tree
from _deprecated.subscriptionHandlers import Tree
gc.collect()
printMemory("After import")
global handler
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CLEAN="$1"
cd esp32_lobo
./esp32_sync.sh
./esp32_build.sh #CLEAN
./esp32_flash.sh /dev/ttyS11
esp32_sync.sh
esp32_build.sh #CLEAN
esp32_flash.sh /dev/ttyS11
#./esp32_initialize.sh
#cd ~/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD/
#./BUILD.sh monitor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CLEAN="$1"
cd esp32_lobo
#./esp32_sync.sh
./esp32_build.sh #CLEAN
./esp32_flash.sh /dev/ttyS4
esp32_build.sh #CLEAN
esp32_flash.sh /dev/ttyS4
#./esp32_initialize.sh
#./esp32_initialize.sh
#cd ~/MicroPython_ESP32_psRAM_LoBo/MicroPython_BUILD/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
125 changes: 0 additions & 125 deletions _dev/listeners/button.py

This file was deleted.

Loading

0 comments on commit 4b88ec0

Please sign in to comment.