From b51347e5ee66314a202651557384075d6d918418 Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Thu, 1 Jul 2021 16:07:49 +0200 Subject: [PATCH] install smbus2 and properly start scripts with python3 --- docs/expert_setup.md | 3 ++- flows/main.json | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/expert_setup.md b/docs/expert_setup.md index 3039ec8..880255d 100644 --- a/docs/expert_setup.md +++ b/docs/expert_setup.md @@ -414,7 +414,8 @@ Raspberry Pi Details: You will also need to install some python modules: ```sh -sudo apt install python3-smbus i2c-tools +sudo apt install i2c-tools +sudo pip3 install smbus2 ``` More information can be found on Yahboom website, on the page [Installing RGB Cooling HAT](https://www.yahboom.net/study/RGB_Cooling_HAT). diff --git a/flows/main.json b/flows/main.json index bad941f..ce66feb 100644 --- a/flows/main.json +++ b/flows/main.json @@ -1413,7 +1413,7 @@ "type": "python3-function", "z": "1371dec5.76e671", "name": "fan control", - "func": "#!/usr/bin/python\nimport smbus2 as smbus\n\nstate = msg[\"payload\"]\n\nbus = smbus.SMBus(1)\n\nDEVICE_ADDRESS = 0x0d\n\ntry:\n # command happens twice, for reasons\n if state == \"off\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n if state == \"on\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\nexcept:\n pass", + "func": "#!/usr/bin/python3\nimport smbus2 as smbus\n\nstate = msg[\"payload\"]\n\nbus = smbus.SMBus(1)\n\nDEVICE_ADDRESS = 0x0d\n\ntry:\n # command happens twice, for reasons\n if state == \"off\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x00)\n if state == \"on\":\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\n bus.write_byte_data(DEVICE_ADDRESS, 0x08, 0x01)\nexcept:\n pass", "outputs": 1, "x": 1110, "y": 40, @@ -6013,7 +6013,7 @@ "type": "python3-function", "z": "9daf9e2b.019fc", "name": "action", - "func": "#!/usr/bin/python\nimport smbus2 as smbus\n\nbus = smbus.SMBus(1)\n#turn off LED\nbus.write_byte_data(0x0d, 0x07, 0x00)\n#turn off Fan\nbus.write_byte_data(0x0d, 0x08, 0x00)\n\n#msg[\"payload\"] = str(msg[\"topic\"])+' now'\nreturn msg", + "func": "#!/usr/bin/python3\nimport smbus2 as smbus\n\nbus = smbus.SMBus(1)\n#turn off LED\nbus.write_byte_data(0x0d, 0x07, 0x00)\n#turn off Fan\nbus.write_byte_data(0x0d, 0x08, 0x00)\n\n#msg[\"payload\"] = str(msg[\"topic\"])+' now'\nreturn msg", "outputs": 1, "x": 590, "y": 720,