Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

coroutine was expected error. Service to call http to local webserver to control LG tv prior 2012 #576

Unanswered
amoranvalero asked this question in Q&A
Discussion options

Hello I am trying to send the power off command to an LG TV prior to 2012 vis http post query.

The code is trigger as a service power_off_async and executed properly (using a tasked coroutine) but I always have an error entry of type TypeError: a coroutine was expected, got None in line 31 at the end of async getSessionid coroutine.

The script:


import sys
import xml.etree.ElementTree as etree
import aiohttp
import asyncio
import platform
headers = {"Content-Type": "application/atom+xml"}
pairCmd = "<?xml version=\"1.0\" encoding=\"utf-8\"?><auth><type>AuthReq</type><value>" \
 + "DDHXTF" + "</value></auth>"
async def getSessionid(csa):
 async with aiohttp.ClientSession() as session:
 response = await session.post(url="http://192.168.1.143:8080/hdcp/api/auth",
 data=pairCmd,
 headers=headers)
 readout = response.text()
 tree = etree.XML(readout)
 sessionId = tree.find('session').text
 
 cmdText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><command><session>" + str(sessionId) \
 + "</session><type>HandleKeyInput</type><value>" \
 + str(csa) \
 + "</value></command>"
 await session.post(url="http://192.168.1.143:8080/hdcp/api/dtv_wifirc",
 data=cmdText,
 headers=headers)
 
 
@service
def power_off_async():
 
 loop = asyncio.get_running_loop()
 task = loop.create_task(getSessionid(8))
 await task

I don't understand since the service power_off_async is called and the tv turn off but there is always an error flagged in the error log of HA.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /