NOTICE: This forum has been archived (i.e. registration and posting is disabled).

Please go to the new forum at https://forum.kylegabriel.com

Notifications
Clear all

[Solved] Output not firing


peakej
(@peakej)
New Member
Joined: 1 month ago
Posts: 2
Topic starter  

Hi, great job on this solution.  I'm struggling to get either python code or scripts to run from the outputs.  My python code runs correctly from the pi, and shows no errors in the Daemon log.  I am obviously missing something fundamental, can somebody please point me in the right direction.

Example off command.

import asyncio
import datetime
import kasa
from kasa import SmartPlug

timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

async def main():
p = SmartPlug("192.168.1.127")

await p.update()
# print(p.alias)
# print(p.has_emeter)
# print(p.is_on)
#await p.turn_on()
await p.turn_off()
await p.update()

log_string = "{ts}: ID: {id}: ON".format(id=output_id, ts=timestamp)
log_state = "{alias}: {state}".format(alias=p.alias, state=str(p.is_on))

self.logger.info(log_string)
self.logger.info("Test Off")

if __name__ == "__main__":
asyncio.run(main())

Log:

2021-04-03 13:01:29,360 - INFO - mycodo.outputs.on_off_python_4feb09b2 - Initialized in 241.0 ms

2021-04-03 13:01:34,693 - DEBUG - mycodo.outputs.on_off_python_4feb09b2 - output_on_off(off, 0, None, 0.0, 0.0, True)

2021-04-03 13:01:34,693 - DEBUG - mycodo.outputs.on_off_python_4feb09b2 - Output 4feb09b2-0e4d-4b14-b43b-24c58621d198 CH0 (Heater KASA Python) OFF at 2021-04-03 13:01:34. Output returned: None

Any guidance will be appreciated.  Thanks.

 


Quote
Topic Tags
peakej
(@peakej)
New Member
Joined: 1 month ago
Posts: 2
Topic starter  

I have been able to use bash scripts to call my Python so can manage without this.  Closing topic.


ReplyQuote