So I have built a custom pool control system in Python. I then used Flask-ask to integrate this with my Echo Dots and Show. With the Echo Show, I was using a simple_card format which reads back all my information while showing it on the screen:
@ask.intent("GetAllStats")
def get_pool_stats():
pool_current_ph = read_database("pool_chemicals", "pool_current_ph")
pool_current_orp = read_database("pool_chemicals", "pool_current_orp")
pool_current_temp = int(float(read_database("system_status", "pool_current_temp")))
pool_level_percentage = read_database("pool_level", "pool_level_percentage")
pic = 'https://richard.mydomian.net/pool_control.jpg'
msg = render_template('our_stats', temperature=pool_current_temp,
ph=pool_current_ph,
orp=pool_current_orp,
level=pool_level_percentage)
return statement(msg).simple_card(title='Pool Control', content='Pool Temperature: {0}\n Pool PH: {1}\n Pool ORP: {2}\n Water Level: {3}% .format(pool_current_temp,pool_current_ph,pool_current_orp,pool_level_percentage))
Here is my our_stats from my templates.yaml:
our_stats: |
<speak>
The pool temperature is currently {{temperature}} degrees. The P H of our pool water is currently {{ph}}, while our oxygen reduction potential
is right at {{orp}}. The level of our water is at {{level}} percent.
</speak>
This works great, but I do not have any font control (that I can find) and the background is always grey.
So I started to research using the display_render
method and I was able to get it to put up a really nice background picture of my pool and still read back my stats, but now I cannot get it to display the information in printed form.
I changed my return statement
above to:
return statement(msg).display_render(template='BodyTemplate3', title='Pool Control', background_image_url=pic)
Again, this works great and reads back my information, but it I try to pass any content to it via textContent
, primaryText
, content
, or text
it always fails. I have also tried various templates including BodyTemplate
's and listTemplate
's. All to no avail. Anytime I try to add content to the screen the skill fails. I remove the content and I get a fantastic picture and it will speak to me all of the information, but that is as far as I can get.
One of the main problems is that I just have not been able to find any pertinent kind of examples using Flask-Ask and the Echo Show with anything but the simple_card.
I am hoping someone has figured this out and can point me in the right direction.
You have to edit your flask-ask models.py.
In the method display_render delete: , 'textContent': text
change:
def display_render(self, template=None, title=None, backButton='HIDDEN', token=None, background_image_url=None, image=None, text=None, hintText=None):
to:
def display_render(self, template=None, title=None, backButton='HIDDEN', token=None, background_image_url=None, image=None, text=None, format=None, hintText=None):
and add after:
if background_image_url is not None:
directive[0]['template']['backgroundImage'] = {
'sources': [
{'url': background_image_url}
]
}
this:
if format == None:
format = 'PlainText'
if text is not None:
directive[0]['template']['textContent'] = {
'primaryText': {
'type': format,
'text': text
},
'secondaryText': {
'type': format,
'text': None
},
'tertiaryText': {
'type': format,
'text': None
}
}
Now you should be able to use:
display_render(template='BodyTemplate6', title='Pool Control', background_image_url=pic, text='Text', format='Format')
I'm using BodyTemplate6 here because some Templates don't support text, format can be 'PlainText' or 'SSML'