Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: expected string or bytes-like object #22

Closed
zraken opened this issue Jul 20, 2020 · 5 comments
Closed

TypeError: expected string or bytes-like object #22

zraken opened this issue Jul 20, 2020 · 5 comments

Comments

@zraken
Copy link

zraken commented Jul 20, 2020

I'm trying a plain vanilla install with all default options but ran into this error:

log file

2020-07-20 09:55:50 ERROR (MainThread) [homeassistant.components.climate] Error while setting up infinitude platform for climate
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/infinitude/climate.py", line 90, in setup_platform
    devices.append(InfinitudeZone(infinitude, zones[i]["id"], zone_name))
  File "/home/homeassistant/.homeassistant/custom_components/infinitude/climate.py", line 183, in __init__
    self.update()
  File "/home/homeassistant/.homeassistant/custom_components/infinitude/climate.py", line 290, in update
    matches = re.match(r'^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})([+-]\d{2}:\d{2})?$', local_time)
  File "/usr/lib/python3.7/re.py", line 173, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

configuration

climate:
  - platform: infinitude
    host: rpi
    port: 3000
    zone_names:
      - Home Zone

response from infinitude for api/status (I don't see 'localTime'):

{"cfgauto":["on"],"cfgcph":["4"],"cfgdead":["2"],"cfgem":["F"],"cfgfan":["on"],"cfgpgm":["on"],"cfgtype":["heatcool"],"filtrlvl":["88"],"humid":["off"],"humlvl":["0"],"mode":["off"],"oat":["80"],"statusCode":["10"],"uvlvl":["0"],"vacat":["off"],"vacatrunning":["off"],"vacend":[{}],"vacstart":[{}],"ventlvl":["0"],"version":"1.3","zones":[{"zone":[{"clsp":["77"],"currentActivity":["manual"],"enabled":["on"],"fan":["off"],"hold":["on"],"htsp":["65"],"id":"1","name":["ZONE 1"],"otmr":["00:00"],"rh":["48"],"rt":["77"]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"2","name":["Zone 2"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"3","name":["Zone 3"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"4","name":["Zone 4"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"5","name":["Zone 5"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"6","name":["Zone 6"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"7","name":["Zone 7"],"otmr":[{}],"rh":["48"],"rt":[{}]},{"clsp":["80"],"currentActivity":["away"],"enabled":["off"],"fan":["off"],"hold":["off"],"htsp":["60"],"id":"8","name":["Zone 8"],"otmr":[{}],"rh":["48"],"rt":[{}]}]}]}
@zraken
Copy link
Author

zraken commented Jul 20, 2020

There appears to be two issues with my Carrier Infinity thermostat status. It is not returning local_time and zone_conditioning (this is marked as "off" under config). I was able to patch a couple of things in climate.py to get it going. Here's what I did: (1) set local_time to current time (2) changed the way _hvac_action is set i.e. changed it to _self.hvac_action = get_safe(self.system_status, "mode").

@lleo19
Copy link

lleo19 commented Oct 6, 2020

There appears to be two issues with my Carrier Infinity thermostat status. It is not returning local_time and zone_conditioning (this is marked as "off" under config). I was able to patch a couple of things in climate.py to get it going. Here's what I did: (1) set local_time to current time (2) changed the way _hvac_action is set i.e. changed it to _self.hvac_action = get_safe(self.system_status, "mode").

@zraken: can you please share your patches, my stat does not return local_time either

@zraken
Copy link
Author

zraken commented Oct 11, 2020

Here's my crappy patch based on this version: https://github.com/MizterB/homeassistant-infinitude/blob/6a1b4985104354e6d7a6c72ab4f2f1e903a65ad3/custom_components/infinitude/climate.py:

155a156
>         #####self._hvac_action = None                # active_heat, active_coo
l, idle, more?
233c234,236
<         self._hvac_action = get_safe(self.zone_status, "zoneconditioning")
---
>         #####self._hvac_action = get_safe(self.zone_status, "zoneconditioning"
)
>         #####self._hvac_action = "idle"
>         self._hvac_action = get_safe(self.system_status, "mode")
289,291c292,302
<         local_time = get_safe(self.system_status, "localTime")
<         matches = re.match(r'^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})([+-]\d{2}:
\d{2})?$', local_time)
<         local_time = matches.group(1)
---
>         #####local_time = get_safe(self.system_status, "localTime")
>         #####matches = re.match(r'^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})([+-]\
d{2}:\d{2})?$', local_time)
>         #####local_time = matches.group(1)
>         #####dt = datetime.datetime.strptime(local_time, "%Y-%m-%dT%H:%M:%S")
>
>         #from datetime import datetime
>         now = datetime.datetime.now()
>         current_time = now.strftime("%Y-%m-%dT%H:%M:%S")
>         local_time = current_time
>         #print("Current Time =", current_time)
>         ##dt = datetime.datetime.strptime(get_safe(self.system_status, "localT
ime"),"%Y-%m-%dT%H:%M:%S")  # Strip the TZ offset, since this is already in loca
l time
430a442,443
>         #####_LOGGER.error("=====Invalid HVAC mode: {}".format(self.hvac_mode)
)
>         #####_LOGGER.error("=====Invalid HVAC action: {}".format(self._hvac_ac
tion))

@bryan-tholen
Copy link

I had a similar issue setting up this integration yesterday. Here is my patch:

--- a/custom_components/infinitude/climate.py
+++ b/custom_components/infinitude/climate.py
@@ -276,7 +276,7 @@ class InfinitudeZone(ClimateEntity):
         self.zone_name = get_safe(self.zone_status, "name")
         self._temperature_unit = get_safe(self.system_config, "cfgem")
         self._current_temperature = float(get_safe(self.zone_status, "rt"))
-        self._hvac_action = get_safe(self.zone_status, "zoneconditioning")
+        self._hvac_action = get_safe(self.system_status, "mode")
         self._current_humidity = float(get_safe(self.zone_status, "rh"))
         self._hvac_mode = get_safe(self.system_config, "mode")
         self.hold_state = get_safe(self.zone_config, "hold")
@@ -339,11 +339,14 @@ class InfinitudeZone(ClimateEntity):
         # Current timestamp can include a TZ offset in some systems.  It should be stripped off
         # since the timestamp is already in the local time.
         local_time = get_safe(self.system_status, "localTime")
-        matches = re.match(
-            r"^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})([+-]\d{2}:\d{2})?$", local_time
-        )
-        local_time = matches.group(1)
-        dt = datetime.datetime.strptime(local_time, "%Y-%m-%dT%H:%M:%S")
+        try:
+            matches = re.match(
+                r"^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})([+-]\d{2}:\d{2})?$", local_time
+            )
+            local_time = matches.group(1)
+            dt = datetime.datetime.strptime(local_time, "%Y-%m-%dT%H:%M:%S")
+        except TypeError:
+            dt = datetime.datetime.now()
 
         while self.activity_next is None:
             day_name = dt.strftime("%A")

@MizterB
Copy link
Owner

MizterB commented Mar 27, 2024

@MizterB MizterB closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants