Skip to content

Commit

Permalink
#32
Browse files Browse the repository at this point in the history
  • Loading branch information
jimboca committed Jan 10, 2019
1 parent fa1118d commit 7e039dd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 24 deletions.
22 changes: 13 additions & 9 deletions ecobee-poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from copy import deepcopy

from node_types import Thermostat, Sensor, Weather
from node_funcs import get_valid_node_name,get_server_data,make_file_dir,get_profile_info
from node_funcs import *

LOGGER = polyinterface.LOGGER

Expand Down Expand Up @@ -370,7 +370,7 @@ def check_profile(self):
self.saveCustomData(cdata)

def write_profile(self):
pfx = 'write_profile:'
pfx = '{}:write_profile:'.format(self.address)
#
# Start the nls with the template data.
#
Expand Down Expand Up @@ -402,7 +402,7 @@ def write_profile(self):
in_h = open('template/editors.xml','r')
for line in in_h:
line = re.sub(r'tstatid',r'{0}'.format(id),line)
line = re.sub(r'tstatcnt',r'{0}'.format(len(self.climates[id])-1),line)
line = re.sub(r'tstatcnt',r'{0}'.format(len(climateList)-1),line)
editor_h.write(line)
in_h.close()
# Then the NLS lines.
Expand All @@ -411,12 +411,16 @@ def write_profile(self):
nls.write('ND-EcobeeC_{0}-ICON = Thermostat\n'.format(id))
nls.write('ND-EcobeeF_{0}-NAME = Ecobee Thermostat {0} (F)\n'.format(id))
nls.write('ND-EcobeeF_{0}-ICON = Thermostat\n'.format(id))
for i in range(11):
if i < len(self.climates[id]):
nls.write("CT_{}-{} = {}\n".format(id,i,self.climates[id][i]['name']))
else:
# Name them with smart<n>
nls.write("CT_{}-{} = smart{}\n".format(id,i,i-2))
customList = deepcopy(climateList)
for i in range(len(climateList)):
name = climateList[i]
# Find this name in the map and replace with our name.
for cli in self.climates[id]:
if cli['ref'] == name:
customList[i] = cli['name']
LOGGER.debug("{} customList={}".format(pfx,customList))
for i in range(len(customList)):
nls.write("CT_{}-{} = {}\n".format(id,i,customList[i]))
nodedef_h.write('</nodedefs>\n')
nodedef_h.close()
editor_h.write('</editors>\n')
Expand Down
23 changes: 23 additions & 0 deletions node_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
import re
import json


def ltom(list):
map = dict()
i = 0
for name in list:
map[name] = i
i += 1
return map

climateList = [
'away',
'home',
'sleep',
'smart1',
'smart2',
'smart3',
'smart4',
'smart5',
'smart6',
'smart7'
]
climateMap = ltom(climateList)

# Removes invalid charaters for ISY Node description
def get_valid_node_name(name):
# Only allow utf-8 characters
Expand Down
14 changes: 0 additions & 14 deletions node_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@
'auto': 3
}

climateMap = {
'away': 0,
'home': 1,
'sleep': 2,
'smart1': 3,
'smart2': 4,
'smart3': 5,
'smart4': 6,
'smart5': 7,
'smart6': 8,
'smart7': 9,
'unknown': 10
}

equipmentStatusMap = {
'off': 0,
'heatPump': 1,
Expand Down
2 changes: 1 addition & 1 deletion profile/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.23
2.0.26b

0 comments on commit 7e039dd

Please sign in to comment.