install smbus2 and properly start scripts with python3

This commit is contained in:
Romain Bazile 2021-07-01 16:07:49 +02:00
parent 71177bc355
commit b51347e5ee
2 changed files with 4 additions and 3 deletions

View file

@ -414,7 +414,8 @@ Raspberry Pi Details:
You will also need to install some python modules: You will also need to install some python modules:
```sh ```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). More information can be found on Yahboom website, on the page [Installing RGB Cooling HAT](https://www.yahboom.net/study/RGB_Cooling_HAT).

View file

@ -1413,7 +1413,7 @@
"type": "python3-function", "type": "python3-function",
"z": "1371dec5.76e671", "z": "1371dec5.76e671",
"name": "fan control", "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, "outputs": 1,
"x": 1110, "x": 1110,
"y": 40, "y": 40,
@ -6013,7 +6013,7 @@
"type": "python3-function", "type": "python3-function",
"z": "9daf9e2b.019fc", "z": "9daf9e2b.019fc",
"name": "action", "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, "outputs": 1,
"x": 590, "x": 590,
"y": 720, "y": 720,