Fix deprecated method (#77)

* Added support to core v19 removing deprecated method to get info form config.

Signed-off-by: mortommy <tommaso.morello@gmail.com>
pull/78/head
mortommy 2019-12-10 11:33:48 +01:00 committed by GitHub
parent 0ee11e8366
commit 25ef8ec252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -32,6 +32,7 @@ If you've forgotten what items have been identified, you can ask Mycroft:
- *"Hey Mycroft, list openhab items"*
## Versions Change Log
* 1.5 addedd support to core v19
* 1.4 added spanish translation
* 1.3 added german translation
* 1.2 addedd python 3 support

View File

@ -37,6 +37,7 @@ import json
# v 1.2 - support to python 3.0
# v 1.3 - support german
# v 1.4 - support spanish
# v 1.5 - support to 19
__author__ = 'mortommy'
@ -48,8 +49,8 @@ class openHABSkill(MycroftSkill):
def __init__(self):
super(openHABSkill, self).__init__(name="openHABSkill")
if self.settings.get('host') is not None and self.settings.get('port') is not None:
self.url = "http://%s:%s/rest" % (self.settings.get('host'), self.settings.get('port'))
if self.get_config('host') is not None and self.get_config('port') is not None:
self.url = "http://%s:%s/rest" % (self.get_config('host'), self.get_config('port'))
else:
self.url = None
@ -64,7 +65,10 @@ class openHABSkill(MycroftSkill):
#self.currentThermostatItemsDic = dict()
self.targetTemperatureItemsDic = dict()
#self.homekitHeatingCoolingModeDic = dict()
def get_config(self, key):
return (self.settings.get(key) or self.config_core.get('openHABSkill', {}).get(key))
def initialize(self):
supported_languages = ["en-US", "it-IT", "de-DE", "es-ES"]
@ -367,9 +371,9 @@ class openHABSkill(MycroftSkill):
self.speak_dialog('ItemNotFoundError')
def handle_websettings_update(self):
if self.settings.get('host') is not None and self.settings.get('port') is not None:
self.url = "http://%s:%s/rest" % (self.settings.get('host'), self.settings.get('port'))
self.getTaggedItems()
if self.get_config('host') is not None and self.get_config('port') is not None:
self.url = "http://%s:%s/rest" % (self.get_config('host'), self.get_config('port'))
self.getTaggedItems()
def sendStatusToItem(self, ohItem, command):
requestUrl = self.url+"/items/%s/state" % (ohItem)