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

Switch device is not working #14

Closed
elucas2uy opened this issue Feb 6, 2018 · 3 comments
Closed

Switch device is not working #14

elucas2uy opened this issue Feb 6, 2018 · 3 comments

Comments

@elucas2uy
Copy link

To fix it I had to add this on "def init(self) : " at switch.py

self.pincnt =pincnt
self.valuecnt=valuecnt
self.stype=stype

@elucas2uy
Copy link
Author

Also some other changes are needed on switch.py to work after a restart....
On init we need to restore the correct values form "datastore" to self.

for example, the most basic to restore is the dxpin, for example adding a line after line 74
....
datastore = self._plugins.readstore(self.devicename)
self.dxpin = datastore['dxpin']
.....

this make the switch to work fine after restart , but maybe some other values are needed too....

@elucas2uy
Copy link
Author

Also something strange is happening with the delay. uPyEasy is not using the selected delay to check for the switch state.
It start ok, but after the first event it start "checking" the switch every second.....

Just one short example:


./micropython -m upyeasy
loaded sink log
loaded sink console
loaded sink syslog
2018-02-07T04:42:31.002 [debug] uPyEasy: Init: Init constructor
2018-02-07T04:42:31.002 [debug] uPyEasy: Init: Entering init
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory config
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory config exception: OSError(17,)
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory plugins
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory plugins exception: OSError(17,)
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory protocols
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory protocols exception: OSError(17,)
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory scripts
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory scripts exception: OSError(17,)
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory rules
2018-02-07 04:42:31 [debug] uPyEasy: Init: Create directory rules exception: OSError(17,)
2018-02-07 04:42:31 [debug] uPyEasy: Init: config Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: network Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: protocol Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: controller Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: hardware Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: dxpin Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: dxmap Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: plugin Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: pluginstore Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: device Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: service Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: notification Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: advanced Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: script Table
2018-02-07 04:42:31 [debug] uPyEasy: Init: rule Table
2018-02-07 04:42:31 [debug] uPyEasy: Hal: Init
2018-02-07 04:42:31 [debug] uPyEasy: Hal: init, network record present
2018-02-07 04:42:31 [debug] uPyEasy: Hal: linux
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Load
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Init protocol records
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Load protocol domoticz_mqtt
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_mqtt
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Load protocol domoticz_http
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Create protocol Record: domoticz_http
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Init protocol records, run async loop
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: Init controller 192.168.1.29-Domoticz MQTT-1
2018-02-07 04:42:31 [debug] uPyEasy: Protocol: domoticz mqtt contruction
2018-02-07 04:42:31 [debug] uPyEasy: Utils: uPyEasy Name
2018-02-07 04:42:31 [debug] uPyEasy: Protocol Domoticz MQTT: Init
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Load
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: init plugin records
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Register frozen plugin switch
2018-02-07 04:42:31 [debug] uPyEasy: Plugin: switch contruction
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Create frozen plugin Record: switch
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Register frozen plugin bme280
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Create frozen plugin Record: bme280
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Register frozen plugin test
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Create frozen plugin Record: test
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Register frozen plugin ds18
2018-02-07 04:42:31 [debug] uPyEasy: Plugin: ds18 contruction
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Create frozen plugin Record: ds18
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Init plugin records, run async loop
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Init device: SW1 with plugin: 1
2018-02-07 04:42:31 [debug] uPyEasy: Protocols: GetQueue controller 192.168.1.29-Domoticz MQTT-1
2018-02-07 04:42:31 [debug] uPyEasy: Plugin: switch contruction
2018-02-07 04:42:31 [debug] uPyEasy: Plugin: switch contruction
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Init device: SW1 ,instantiate plugin: Switch
2018-02-07 04:42:31 [debug] uPyEasy: Utils: uPyEasy Name
2018-02-07 04:42:31 [debug] uPyEasy: Plugin: switch init
2018-02-07 04:42:31 [debug] uPyEasy: Plugins: Read device store: SW1
2018-02-07 04:42:32 [debug] uPyEasy: Plugin: switch init normal, pin: d16
2018-02-07 04:42:32 [debug] uPyEasy: Hal: pin = d16
2018-02-07 04:42:32 [debug] uPyEasy: Hal: pin linux: 16
2018-02-07 04:42:32 [debug] uPyEasy: Scripts: Load
2018-02-07 04:42:32 [debug] uPyEasy: Scripts: Init
2018-02-07 04:42:32 [debug] uPyEasy: Plugins: GetQueue
2018-02-07 04:42:32 [debug] uPyEasy: Scripts: init scripts records
2018-02-07 04:42:32 [debug] uPyEasy: Scripts: init rules records
2018-02-07 04:42:32 [debug] uPyEasy: Scripts: Init script/rule records, run async loop
2018-02-07 04:42:32 [debug] uPyEasy: Utils: Sys hostname
2018-02-07 04:42:32 [debug] uPyEasy: Utils: uPyEasy Name
Set syslog hostname 0.0.0.0
reloaded sink syslog
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Hal: Entering SetTime
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Main: Pre-loading home page
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Hal: get_ip_address linux, ip: 192.168.1.28
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Main: uPyEasy Main Async Loop
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Scripts: Async processing scripts/rules
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Protocols: Async processing protocols
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Plugins: Async processing plugins
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:32 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:37 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:38 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:38 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:43 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:43 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:43 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:47 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:47 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT Processing...
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: send SENSOR_TYPE_SWITCH
2018-02-07 04:42:48 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: connect
2018-02-07 04:42:49 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: SENSOR_TYPE_SWITCH
2018-02-07 04:42:49 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: QueueOUT: domoticz/in Message: {"idx": 33, "switchcmd": "On", "command": "switchlight"}
2018-02-07 04:42:50 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:50 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:52 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:52 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:52 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT Processing...
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: send SENSOR_TYPE_SWITCH
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: connect
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: SENSOR_TYPE_SWITCH
2018-02-07 04:42:53 [debug] uPyEasy-uPyEasy: Protocol Domoticz MQTT: QueueOUT: domoticz/in Message: {"idx": 33, "switchcmd": "Off", "command": "switchlight"}
2018-02-07 04:42:55 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:55 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:55 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:57 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:57 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:57 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:42:58 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:42:58 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:42:58 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:00 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:00 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:00 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:02 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:02 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:02 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:03 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:03 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:03 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:05 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:05 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:05 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:07 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:07 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:07 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5
2018-02-07 04:43:08 [debug] uPyEasy-uPyEasy: Plugin: switch process
2018-02-07 04:43:08 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: Switch
2018-02-07 04:43:08 [debug] uPyEasy-uPyEasy: Plugins: Scheduling Async processing plugin: 1, Delay: 5

Note: the lines "Plugins: Scheduling Async processing plugin: 1, Delay: 5" are there for an extra debugging trying to figure it out whats going wrong....

@Lisa999
Copy link
Contributor

Lisa999 commented Feb 18, 2018

Actually, the bug is that it is called at all! It shouldn't call the switch plugin unless the switch is pressed and the lock therefor (lines 180-208) is released...
Bug1: Fixed in v0.2.1
Bug2: create #16 for this
Bug3: fixed in v0.2.1

@Lisa999 Lisa999 closed this as completed Feb 18, 2018
Lisa999 pushed a commit that referenced this issue Feb 18, 2018
Fixed #11
Lisa999 added a commit that referenced this issue Feb 18, 2018
Fixed issues #11 #14
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

2 participants