Error running sample code #4

Closed
opened 2024-01-21 16:23:48 +00:00 by Topsham · 5 comments

Hi andrius if I run your sample code below (neo1.py) as you will see from the output below the debugging shows connecting OK (I have only one stat 'Study' at present) but I then get TypeError: cannot unpack non-iterable types.SimpleNamespace object. Any help/suggestions would be appreciated. Thanks

#!/usr/bin/env python3

# SPDX-FileCopyrightText: 2020-2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: MIT


import asyncio
import datetime
import logging
import neohubapi.neohub as neohub

from neohubapi.enums import ScheduleFormat


async def run():
    hub = neohub.NeoHub("192.168.0.33")
    system = await hub.get_system()
    hub_data, devices = await hub.get_live_data()

    print("Thermostats:")
    for device in devices['thermostats']:
        print(f"Target temperature of {device.name}: {device.target_temperature}")
        await device.identify()

    print("Timeclocks:")
    for device in devices['timeclocks']:
        print(f"Timeclock {device.name}: {device.target_temperature}")
        print(await hub.set_timer_hold(False, 1, [device]))

    print(await hub.target_temperature_step)


def main():
    logging.basicConfig(level=logging.DEBUG)
    asyncio.run(run())


if (__name__ == '__main__'):
    main()

pi@raspberrypi:~/nhub $ sudo python3 neo1.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:neohub:Using legacy connection
DEBUG:neohub:Sending message: bytearray(b'{"GET_SYSTEM": 0}\x00\r')
DEBUG:neohub:Received message: {"ALT_TIMER_FORMAT":null,"COOLBOX":"heating","COOLBOX_OVERRIDE":null,"COOLBOX_PRESENT":0,"CORF":"C","DEVICE_ID":"NeoHub","DST_AUTO":true,"DST_ON":false,"EXTENDED_HISTORY":"off","FORMAT":2,"GDEVLIST":[1],"GLOBAL_HC_MODE":"heating","GLOBAL_SYSTEM_TYPE":"HeatOnly","HEATING_LEVELS":4,"HUB_TYPE":2,"HUB_VERSION":2161,"LEGACY_LOCAL_PORT":true,"NTP_ON":"Running","PARTITION":"4","TIMESTAMP":0,"TIMEZONESTR":null,"TIME_ZONE":0.0,"UTC":1705852282}

DEBUG:neohub:Using legacy connection
DEBUG:neohub:Sending message: bytearray(b'{"GET_LIVE_DATA": 0}\x00\r')
DEBUG:neohub:Received message: {"CLOSE_DELAY":0,"COOL_INPUT":false,"HOLIDAY_END":0,"HUB_AWAY":false,"HUB_HOLIDAY":false,"HUB_TIME":1705852282,"OPEN_DELAY":0,"TIMESTAMP_DEVICE_LISTS":1705759477,"TIMESTAMP_ENGINEERS":1705759488,"TIMESTAMP_PROFILE_0":1705759495,"TIMESTAMP_PROFILE_COMFORT_LEVELS":0,"TIMESTAMP_PROFILE_TIMERS":0,"TIMESTAMP_PROFILE_TIMERS_0":1705759502,"TIMESTAMP_RECIPES":0,"TIMESTAMP_SYSTEM":0,"devices":[{"ACTIVE_LEVEL":1,"ACTIVE_PROFILE":0,"ACTUAL_TEMP":"24.5","AVAILABLE_MODES":["heat"],"AWAY":false,"COOL_MODE":false,"COOL_ON":false,"COOL_TEMP":127.50,"CURRENT_FLOOR_TEMPERATURE":127.50,"DATE":"sunday","DEVICE_ID":1,"FAN_CONTROL":"Manual","FAN_SPEED":"Off","FLOOR_LIMIT":false,"HC_MODE":"HEATING","HEAT_MODE":true,"HEAT_ON":false,"HOLD_COOL":127.50,"HOLD_OFF":true,"HOLD_ON":false,"HOLD_TEMP":21,"HOLD_TIME":"0:00","HOLIDAY":false,"LOCK":false,"LOW_BATTERY":false,"MANUAL_OFF":true,"MODELOCK":false,"MODULATION_LEVEL":0,"OFFLINE":false,"PIN_NUMBER":"0000","PREHEAT_ACTIVE":false,"PRG_TEMP":0,"PRG_TIMER":false,"RECENT_TEMPS":["24.0","23.9","24.1","24.0","24.1","24.1","24.0","23.8","23.8","23.7","23.7","23.7","23.6","23.6","23.6","23.6","23.6","23.6","23.6","23.5","23.5","23.5","23.4","23.4","23.3","23.3","23.2","23.2","23.2","23.1","23.1","23.1","23.0","23.0","22.9","22.9","22.9","22.9","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.7","22.7","22.7","22.7","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.9","22.8","22.8","22.9","22.9","23.1","23.2","23.3","23.3","23.4","23.4","23.4","23.5","23.5","23.6","23.4","23.4","23.7","23.8","23.8","23.6","23.6","23.5","23.8","23.9","24.0","24.0","24.0","24.0","24.0","24.0","24.2","24.3","24.4","24.4"],"RELATIVE_HUMIDITY":0,"SET_TEMP":"12.0","STANDBY":true,"SWITCH_DELAY_LEFT":"0:00","TEMPORARY_SET_FLAG":false,"THERMOSTAT":true,"TIME":"15:51","TIMER_ON":false,"WINDOW_OPEN":false,"WRITE_COUNT":5,"ZONE_NAME":"Study"}]}

Traceback (most recent call last):
File "neo1.py", line 39, in
main()
File "neo1.py", line 36, in main
asyncio.run(run())
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "neo1.py", line 18, in run
hub_data, devices = await hub.get_live_data()
TypeError: cannot unpack non-iterable types.SimpleNamespace object
pi@raspberrypi:~/nhub $ sudo nano neo1.py
pi@raspberrypi:~/nhub $ sudo python3 neo1.py
Traceback (most recent call last):
File "neo1.py", line 40, in
main()
NameError: name 'main' is not defined
pi@raspberrypi:~/nhub $ sudo nano neo1.py
pi@raspberrypi:~/nhub $ sudo python3 neo1.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:neohub:Using legacy connection
DEBUG:neohub:Sending message: bytearray(b'{"GET_SYSTEM": 0}\x00\r')
DEBUG:neohub:Received message: {"ALT_TIMER_FORMAT":null,"COOLBOX":"heating","COOLBOX_OVERRIDE":null,"COOLBOX_PRESENT":0,"CORF":"C","DEVICE_ID":"NeoHub","DST_AUTO":true,"DST_ON":false,"EXTENDED_HISTORY":"off","FORMAT":2,"GDEVLIST":[1],"GLOBAL_HC_MODE":"heating","GLOBAL_SYSTEM_TYPE":"HeatOnly","HEATING_LEVELS":4,"HUB_TYPE":2,"HUB_VERSION":2161,"LEGACY_LOCAL_PORT":true,"NTP_ON":"Running","PARTITION":"4","TIMESTAMP":0,"TIMEZONESTR":null,"TIME_ZONE":0.0,"UTC":1705854062}

DEBUG:neohub:Using legacy connection
DEBUG:neohub:Sending message: bytearray(b'{"GET_LIVE_DATA": 0}\x00\r')
DEBUG:neohub:Received message: {"CLOSE_DELAY":0,"COOL_INPUT":false,"HOLIDAY_END":0,"HUB_AWAY":false,"HUB_HOLIDAY":false,"HUB_TIME":1705854062,"OPEN_DELAY":0,"TIMESTAMP_DEVICE_LISTS":1705759477,"TIMESTAMP_ENGINEERS":1705759488,"TIMESTAMP_PROFILE_0":1705759495,"TIMESTAMP_PROFILE_COMFORT_LEVELS":0,"TIMESTAMP_PROFILE_TIMERS":0,"TIMESTAMP_PROFILE_TIMERS_0":1705759502,"TIMESTAMP_RECIPES":0,"TIMESTAMP_SYSTEM":0,"devices":[{"ACTIVE_LEVEL":1,"ACTIVE_PROFILE":0,"ACTUAL_TEMP":"24.6","AVAILABLE_MODES":["heat"],"AWAY":false,"COOL_MODE":false,"COOL_ON":false,"COOL_TEMP":127.50,"CURRENT_FLOOR_TEMPERATURE":127.50,"DATE":"sunday","DEVICE_ID":1,"FAN_CONTROL":"Manual","FAN_SPEED":"Off","FLOOR_LIMIT":false,"HC_MODE":"HEATING","HEAT_MODE":true,"HEAT_ON":false,"HOLD_COOL":127.50,"HOLD_OFF":true,"HOLD_ON":false,"HOLD_TEMP":21,"HOLD_TIME":"0:00","HOLIDAY":false,"LOCK":false,"LOW_BATTERY":false,"MANUAL_OFF":true,"MODELOCK":false,"MODULATION_LEVEL":0,"OFFLINE":false,"PIN_NUMBER":"0000","PREHEAT_ACTIVE":false,"PRG_TEMP":0,"PRG_TIMER":false,"RECENT_TEMPS":["24.1","24.0","24.1","24.1","24.0","23.8","23.8","23.7","23.7","23.7","23.6","23.6","23.6","23.6","23.6","23.6","23.6","23.5","23.5","23.5","23.4","23.4","23.3","23.3","23.2","23.2","23.2","23.1","23.1","23.1","23.0","23.0","22.9","22.9","22.9","22.9","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.7","22.7","22.7","22.7","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.9","22.8","22.8","22.9","22.9","23.1","23.2","23.3","23.3","23.4","23.4","23.4","23.5","23.5","23.6","23.4","23.4","23.7","23.8","23.8","23.6","23.6","23.5","23.8","23.9","24.0","24.0","24.0","24.0","24.0","24.0","24.2","24.3","24.4","24.4","24.5","24.5"],"RELATIVE_HUMIDITY":0,"SET_TEMP":"12.0","STANDBY":true,"SWITCH_DELAY_LEFT":"0:00","TEMPORARY_SET_FLAG":false,"THERMOSTAT":true,"TIME":"16:20","TIMER_ON":false,"WINDOW_OPEN":false,"WRITE_COUNT":5,"ZONE_NAME":"Study"}]}

Traceback (most recent call last):
File "neo1.py", line 39, in
main()
File "neo1.py", line 35, in main
asyncio.run(run())
File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "neo1.py", line 18, in run
hub_data, devices = await hub.get_live_data()
TypeError: cannot unpack non-iterable types.SimpleNamespace object
pi@raspberrypi:~/nhub $

Hi andrius if I run your sample code below (neo1.py) as you will see from the output below the debugging shows connecting OK (I have only one stat 'Study' at present) but I then get TypeError: cannot unpack non-iterable types.SimpleNamespace object. Any help/suggestions would be appreciated. Thanks ``` #!/usr/bin/env python3 # SPDX-FileCopyrightText: 2020-2021 Andrius Štikonas <andrius@stikonas.eu> # SPDX-License-Identifier: MIT import asyncio import datetime import logging import neohubapi.neohub as neohub from neohubapi.enums import ScheduleFormat async def run(): hub = neohub.NeoHub("192.168.0.33") system = await hub.get_system() hub_data, devices = await hub.get_live_data() print("Thermostats:") for device in devices['thermostats']: print(f"Target temperature of {device.name}: {device.target_temperature}") await device.identify() print("Timeclocks:") for device in devices['timeclocks']: print(f"Timeclock {device.name}: {device.target_temperature}") print(await hub.set_timer_hold(False, 1, [device])) print(await hub.target_temperature_step) def main(): logging.basicConfig(level=logging.DEBUG) asyncio.run(run()) if (__name__ == '__main__'): main() ``` pi@raspberrypi:~/nhub $ sudo python3 neo1.py DEBUG:asyncio:Using selector: EpollSelector DEBUG:neohub:Using legacy connection DEBUG:neohub:Sending message: bytearray(b'{"GET_SYSTEM": 0}\x00\r') DEBUG:neohub:Received message: {"ALT_TIMER_FORMAT":null,"COOLBOX":"heating","COOLBOX_OVERRIDE":null,"COOLBOX_PRESENT":0,"CORF":"C","DEVICE_ID":"NeoHub","DST_AUTO":true,"DST_ON":false,"EXTENDED_HISTORY":"off","FORMAT":2,"GDEVLIST":[1],"GLOBAL_HC_MODE":"heating","GLOBAL_SYSTEM_TYPE":"HeatOnly","HEATING_LEVELS":4,"HUB_TYPE":2,"HUB_VERSION":2161,"LEGACY_LOCAL_PORT":true,"NTP_ON":"Running","PARTITION":"4","TIMESTAMP":0,"TIMEZONESTR":null,"TIME_ZONE":0.0,"UTC":1705852282} DEBUG:neohub:Using legacy connection DEBUG:neohub:Sending message: bytearray(b'{"GET_LIVE_DATA": 0}\x00\r') DEBUG:neohub:Received message: {"CLOSE_DELAY":0,"COOL_INPUT":false,"HOLIDAY_END":0,"HUB_AWAY":false,"HUB_HOLIDAY":false,"HUB_TIME":1705852282,"OPEN_DELAY":0,"TIMESTAMP_DEVICE_LISTS":1705759477,"TIMESTAMP_ENGINEERS":1705759488,"TIMESTAMP_PROFILE_0":1705759495,"TIMESTAMP_PROFILE_COMFORT_LEVELS":0,"TIMESTAMP_PROFILE_TIMERS":0,"TIMESTAMP_PROFILE_TIMERS_0":1705759502,"TIMESTAMP_RECIPES":0,"TIMESTAMP_SYSTEM":0,"devices":[{"ACTIVE_LEVEL":1,"ACTIVE_PROFILE":0,"ACTUAL_TEMP":"24.5","AVAILABLE_MODES":["heat"],"AWAY":false,"COOL_MODE":false,"COOL_ON":false,"COOL_TEMP":127.50,"CURRENT_FLOOR_TEMPERATURE":127.50,"DATE":"sunday","DEVICE_ID":1,"FAN_CONTROL":"Manual","FAN_SPEED":"Off","FLOOR_LIMIT":false,"HC_MODE":"HEATING","HEAT_MODE":true,"HEAT_ON":false,"HOLD_COOL":127.50,"HOLD_OFF":true,"HOLD_ON":false,"HOLD_TEMP":21,"HOLD_TIME":"0:00","HOLIDAY":false,"LOCK":false,"LOW_BATTERY":false,"MANUAL_OFF":true,"MODELOCK":false,"MODULATION_LEVEL":0,"OFFLINE":false,"PIN_NUMBER":"0000","PREHEAT_ACTIVE":false,"PRG_TEMP":0,"PRG_TIMER":false,"RECENT_TEMPS":["24.0","23.9","24.1","24.0","24.1","24.1","24.0","23.8","23.8","23.7","23.7","23.7","23.6","23.6","23.6","23.6","23.6","23.6","23.6","23.5","23.5","23.5","23.4","23.4","23.3","23.3","23.2","23.2","23.2","23.1","23.1","23.1","23.0","23.0","22.9","22.9","22.9","22.9","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.7","22.7","22.7","22.7","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.9","22.8","22.8","22.9","22.9","23.1","23.2","23.3","23.3","23.4","23.4","23.4","23.5","23.5","23.6","23.4","23.4","23.7","23.8","23.8","23.6","23.6","23.5","23.8","23.9","24.0","24.0","24.0","24.0","24.0","24.0","24.2","24.3","24.4","24.4"],"RELATIVE_HUMIDITY":0,"SET_TEMP":"12.0","STANDBY":true,"SWITCH_DELAY_LEFT":"0:00","TEMPORARY_SET_FLAG":false,"THERMOSTAT":true,"TIME":"15:51","TIMER_ON":false,"WINDOW_OPEN":false,"WRITE_COUNT":5,"ZONE_NAME":"Study"}]} Traceback (most recent call last): File "neo1.py", line 39, in <module> main() File "neo1.py", line 36, in main asyncio.run(run()) File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete return future.result() File "neo1.py", line 18, in run hub_data, devices = await hub.get_live_data() TypeError: cannot unpack non-iterable types.SimpleNamespace object pi@raspberrypi:~/nhub $ sudo nano neo1.py pi@raspberrypi:~/nhub $ sudo python3 neo1.py Traceback (most recent call last): File "neo1.py", line 40, in <module> main() NameError: name 'main' is not defined pi@raspberrypi:~/nhub $ sudo nano neo1.py pi@raspberrypi:~/nhub $ sudo python3 neo1.py DEBUG:asyncio:Using selector: EpollSelector DEBUG:neohub:Using legacy connection DEBUG:neohub:Sending message: bytearray(b'{"GET_SYSTEM": 0}\x00\r') DEBUG:neohub:Received message: {"ALT_TIMER_FORMAT":null,"COOLBOX":"heating","COOLBOX_OVERRIDE":null,"COOLBOX_PRESENT":0,"CORF":"C","DEVICE_ID":"NeoHub","DST_AUTO":true,"DST_ON":false,"EXTENDED_HISTORY":"off","FORMAT":2,"GDEVLIST":[1],"GLOBAL_HC_MODE":"heating","GLOBAL_SYSTEM_TYPE":"HeatOnly","HEATING_LEVELS":4,"HUB_TYPE":2,"HUB_VERSION":2161,"LEGACY_LOCAL_PORT":true,"NTP_ON":"Running","PARTITION":"4","TIMESTAMP":0,"TIMEZONESTR":null,"TIME_ZONE":0.0,"UTC":1705854062} DEBUG:neohub:Using legacy connection DEBUG:neohub:Sending message: bytearray(b'{"GET_LIVE_DATA": 0}\x00\r') DEBUG:neohub:Received message: {"CLOSE_DELAY":0,"COOL_INPUT":false,"HOLIDAY_END":0,"HUB_AWAY":false,"HUB_HOLIDAY":false,"HUB_TIME":1705854062,"OPEN_DELAY":0,"TIMESTAMP_DEVICE_LISTS":1705759477,"TIMESTAMP_ENGINEERS":1705759488,"TIMESTAMP_PROFILE_0":1705759495,"TIMESTAMP_PROFILE_COMFORT_LEVELS":0,"TIMESTAMP_PROFILE_TIMERS":0,"TIMESTAMP_PROFILE_TIMERS_0":1705759502,"TIMESTAMP_RECIPES":0,"TIMESTAMP_SYSTEM":0,"devices":[{"ACTIVE_LEVEL":1,"ACTIVE_PROFILE":0,"ACTUAL_TEMP":"24.6","AVAILABLE_MODES":["heat"],"AWAY":false,"COOL_MODE":false,"COOL_ON":false,"COOL_TEMP":127.50,"CURRENT_FLOOR_TEMPERATURE":127.50,"DATE":"sunday","DEVICE_ID":1,"FAN_CONTROL":"Manual","FAN_SPEED":"Off","FLOOR_LIMIT":false,"HC_MODE":"HEATING","HEAT_MODE":true,"HEAT_ON":false,"HOLD_COOL":127.50,"HOLD_OFF":true,"HOLD_ON":false,"HOLD_TEMP":21,"HOLD_TIME":"0:00","HOLIDAY":false,"LOCK":false,"LOW_BATTERY":false,"MANUAL_OFF":true,"MODELOCK":false,"MODULATION_LEVEL":0,"OFFLINE":false,"PIN_NUMBER":"0000","PREHEAT_ACTIVE":false,"PRG_TEMP":0,"PRG_TIMER":false,"RECENT_TEMPS":["24.1","24.0","24.1","24.1","24.0","23.8","23.8","23.7","23.7","23.7","23.6","23.6","23.6","23.6","23.6","23.6","23.6","23.5","23.5","23.5","23.4","23.4","23.3","23.3","23.2","23.2","23.2","23.1","23.1","23.1","23.0","23.0","22.9","22.9","22.9","22.9","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.7","22.7","22.7","22.7","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.8","22.9","22.8","22.8","22.9","22.9","23.1","23.2","23.3","23.3","23.4","23.4","23.4","23.5","23.5","23.6","23.4","23.4","23.7","23.8","23.8","23.6","23.6","23.5","23.8","23.9","24.0","24.0","24.0","24.0","24.0","24.0","24.2","24.3","24.4","24.4","24.5","24.5"],"RELATIVE_HUMIDITY":0,"SET_TEMP":"12.0","STANDBY":true,"SWITCH_DELAY_LEFT":"0:00","TEMPORARY_SET_FLAG":false,"THERMOSTAT":true,"TIME":"16:20","TIMER_ON":false,"WINDOW_OPEN":false,"WRITE_COUNT":5,"ZONE_NAME":"Study"}]} Traceback (most recent call last): File "neo1.py", line 39, in <module> main() File "neo1.py", line 35, in main asyncio.run(run()) File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete return future.result() File "neo1.py", line 18, in run hub_data, devices = await hub.get_live_data() TypeError: cannot unpack non-iterable types.SimpleNamespace object pi@raspberrypi:~/nhub $
Owner

Hmm, probably caused by 3ad3a73bb8

Let's see if I can come up with new example code...

Hmm, probably caused by https://git.stikonas.eu/andrius/neohubapi/commit/3ad3a73bb83b56eda11410662546fee6021f3fab Let's see if I can come up with new example code...
Author

That would be very helpful. Thanks

That would be very helpful. Thanks
Owner

Hmm, probably caused by 3ad3a73bb8

Let's see if I can come up with new example code...

That would be very helpful. Thanks

try this snippet (though make sure to git pull before that:

    system = await hub.get_system()
    hub_data = await hub.get_devices_data()
    devices = hub_data['neo_devices']

    print("Thermostats:")
    for device in devices:
        print(f"Target temperature of {device.name}: {device.temperature}")
        await device.identify()

I still need to figure out that timeclock change...

Hmm, probably caused by https://git.stikonas.eu/andrius/neohubapi/commit/3ad3a73bb83b56eda11410662546fee6021f3fab Let's see if I can come up with new example code... > That would be very helpful. Thanks try this snippet (though make sure to `git pull` before that: ``` system = await hub.get_system() hub_data = await hub.get_devices_data() devices = hub_data['neo_devices'] print("Thermostats:") for device in devices: print(f"Target temperature of {device.name}: {device.temperature}") await device.identify() ``` I still need to figure out that timeclock change...
Owner

Hmm, I think just remove that timeclocks section...

Hmm, I think just remove that timeclocks section...
Owner

Ok, I pushed the new readme both here and on the gitlab... Let me know if it works, then I'll close this issue.

Ok, I pushed the new readme both here and on the gitlab... Let me know if it works, then I'll close this issue.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: andrius/neohubapi#4
No description provided.