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

Added possibility to define the data type of Homematic #24078

Merged
merged 3 commits into from
May 24, 2019
Merged

Added possibility to define the data type of Homematic #24078

merged 3 commits into from
May 24, 2019

Conversation

p0l0
Copy link
Contributor

@p0l0 p0l0 commented May 24, 2019

Description:

The Homematic CCU needs that we send the correct XML-RPC Data Type for setValue, but parsing the yaml will always return a string.

This example request will be ignored by CCU:

<?xml version="1.0"?>
<methodCall>
	<methodName>setValue</methodName>
	<params>
		<param>
			<value><string>INT0000001:1</string></value>
		</param>
		<param>
			<value><string>ACTIVE_PROFILE</string></value>
		</param>
		<param>
			<value><string>2</string></value>
		</param>
	</params>
</methodCall>

the value should be a int:

<?xml version="1.0"?>
<methodCall>
	<methodName>setValue</methodName>
	<params>
		<param>
			<value><string>INT0000001:1</string></value>
		</param>
		<param>
			<value><string>ACTIVE_PROFILE</string></value>
		</param>
		<param>
			<value><int>2</int></value>
		</param>
	</params>
</methodCall>

Homematic component uses pyhomematic and pyhomematic uses xmlrpc.client.ServerProxy, an as stated under https://docs.python.org/3/library/xmlrpc.client.html#xmlrpc.client.ServerProxy, python data types are converted into the correct XML-RPC Type.

I added an optional value_type parameter where you are able to define the desired data type. Supported data types are (I just used the same naming as XML-RPC Types):

  • boolean
  • dateTime.iso8601
  • double
  • int
  • string

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#9513

Example entry for automation.yaml:

- alias: changeProfile
  trigger:
    - platform: time
      at: '00:00:05'
  action:
    - service: homematic.set_device_value
      data_template:
        address: 'INT0000001'
        channel: 1
        param: 'ACTIVE_PROFILE'
        interface: groups
        value_type: 'int'
        value: >
          {% if ((states('sensor.week_number')|default(0)|int) % 2) == 0 %}
          1
          {% else %}
          2
          {% endif %}

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

Hi @p0l0,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@ghost
Copy link

ghost commented May 24, 2019

Hey there @pvizeli, @danielperna84, mind taking a look at this pull request as its been labeled with a integration (homematic) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

@fabaff fabaff changed the title Homematic: Added possibility to define the data type for set_device_v… Added possibility to define the data type of Homematic May 24, 2019
Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to the library. Home Assistant consume data only

@pvizeli
Copy link
Member

pvizeli commented May 24, 2019

I see, that is for the service call.

@pvizeli pvizeli merged commit ca2a682 into home-assistant:dev May 24, 2019
@p0l0 p0l0 deleted the homematic-setvalue-type branch May 24, 2019 17:37
@balloob balloob mentioned this pull request Jun 4, 2019
alandtse pushed a commit to alandtse/home-assistant that referenced this pull request Oct 12, 2019
…t#24078)

* Homematic: Added possibility to define the data type for set_device_value

* Fixed coding style

* Fixed variable name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants