After updating my raspberry 1 B+ with 2.0 Agent I lost my Schedule, turn relay on at morning, and turn off at midnight. So I made a Python program to control this GPIO and I added to crontab at specific time. After doing this I have rebooted and Schedule Works fine but I lost control from Cayenne Dashboard. I rewind everything to start and problem not solved. So I left the cron Schedule but I want to recover cayenne control.
My py is:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
GPIO.output(21,GPIO.HIGH)
and other same with:
GPIO.output(21,GPIO.LOW)
my contrab text is:
0 07 * * * python /home/pi/python/Relay_ON.py
0 01 * * * python /home/pi/python/Relay_OFF.py
Can somebody tell me what is happening? Please
See if the cayenne service is running service myDevices status
and the log tail -f /var/logs/myDevices/cayenne.log
1 Like
Hi Shramik, I’m not at home but I remember that agent.db has an error, don’t remember which one and:
pam_exec(login:session): conversation failed
and webiopi was not working, I don’t if with this new agent it’s normal or not.
And my dashboard is working well, Online, but just when I want to switch on/off this relay is not working, just with python, if you need more information, just ask, thanks
@jburhenn tagging for this.
@stefschin Yeah, webiopi is no longer needed with the new agent so that is normal.
So just manually switching on/off from the dashboard fails? Can you attempt to switch it on/off and post the /var/logs/myDevices/cayenne.log
data from that test? Also, how does the widget behave when you try to switch it on/off? Does it get stuck showing the spinning circles or does it revert to the standard on/off button icon?
Hi J, ok with webiopi, yes, just switching on/off from dashboard same gpio as I use it with python. In app just revert icon until I quit and enter again and stays off, in dashboard show spinning circles and after about 20-30 seconds stay off and nothing happens to GPIO 21
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/myDevices-2.0.1-py3.4.egg/myDevices/sensors/sensors.py", line 184, in SensorsInfo
cayennemqtt.DataChannel.add(sensors_info, cayennemqtt.DEV_SENSOR, channel, value=self.CallDeviceFunction(func), name=display_name, **sensor_type['data_args'])
File "/usr/local/lib/python3.4/dist-packages/myDevices-2.0.1-py3.4.egg/myDevices/sensors/sensors.py", line 131, in CallDeviceFunction
response = value_type(func.format % result)
ValueError: invalid literal for int() with base 10: '0.00'
2018-07-25 00:23:54 - myDevices - INFO - Send changed data: [{'sys:cpu;load': 5.1}, {'sys:ram;usage': 198348800}, {'sys:storage:/;usage': 5093376000}]
2018-07-25 00:24:00 - myDevices - INFO - OnMessage: {'cmdId': 'FEwEvMKz64yMzGz', 'payload': '1', 'channel': 'dev:Ezpvpq4ErELtLKq'}
2018-07-25 00:24:00 - myDevices - INFO - ExecuteMessage: {'cmdId': 'FEwEvMKz64yMzGz', 'payload': '1', 'channel': 'dev:Ezpvpq4ErELtLKq'}
2018-07-25 00:24:00 - myDevices - INFO - SensorCommand: value, sensor Ezpvpq4ErELtLKq, channel None, value 1
2018-07-25 00:24:00 - myDevices - INFO - Sensor found: {'device': <helper.RelaySwitch object at 0xb600efb0>, 'description': 'Lamp', 'args': {'invert': True, 'gpio': 'GPIO', 'channel': 21}, 'type': ['DigitalActuator'], 'functions': {'GET': {}, 'POST': {}}, 'origin': 'rest', 'status': 1, 'class': 'RelaySwitch'}
2018-07-25 00:24:01 - myDevices - INFO - ok,FEwEvMKz64yMzGz
2018-07-25 00:24:03 - myDevices - INFO - Send changed data: [{'sys:cpu;load': 3.0}, {'sys:ram;usage': 198356992}]
2018-07-25 00:24:11 - myDevices - INFO - Send changed data: [{'sys:cpu;load': 1.0}, {'sys:ram;usage': 198352896}, {'sys:storage:/;usage': 5093380096}]
2018-07-25 00:24:14 - myDevices - INFO - Send system state: 63 items
i guess you are familiar with python, so you can try adding a new device to cayenne using GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API
1 Like
You mean that I turn this switch on/off with python instead of agent?
If @jburhenn not find anything to do, I will try your advise, thanks
Strange. That log doesn’t seem to show any errors. I’m not sure what the issue would be.
Can you post the output of this command: ls -l /sys/class/gpio/gpio21/
?
Also, can you run the commands below, then try to switch the state using Cayenne, then run them again and post the output here?
cat /sys/class/gpio/gpio21/direction
cat /sys/class/gpio/gpio21/value
1 Like
It works again!!! thanks, I do what you say and when I test switch in cayenne I saw that it was on, I turn gpio off with python and then turn off Cayenne switch, but after that, I turn it on and it works, I don’t know what append.
Thanks @jburhenn
1 Like
Glad that’s working for you now. If you see the issue again, please let us know.
1 Like
Yes @jburhenn, I have seen issue again but I find a way to correct it, in GPIO menu from cayenne, GPIO is set to IN, I touch it on my app to change to OUT and it works again! I hope it helps, Cheers
when you add an actuator widget to the integrated GPIO pin it automatically assign that pin as output and LOW/HIGH depending on the state the button is currently.
Can you try adding another button and check the state of GPIO in the menu. Try a refresh of the app if it does not show up.